Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Chapel Hill, North Carolina, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    We download a report with hospital patient information every morning in .CSV format - see attached file (I had to change the file type to .txt to upload - original file extension is .csv) - and need to convert the data into a Word file with the data in tables as shown in the attached Word document. Note - examples have fictional data. I know how to store data in a text file. Is there an easy way to open a Word Document store the first patient name and then store the patient info in a table - one table per patient, each table with one row and three columns. And then repeat the pattern for each patient in the same file. End result is one file with one 'header' row and one table per patient. (note that the bolded titles in the Word file are the column headers in the .csv file.

    Thanks!

    Larry
    Attached Files Attached Files

  2. #2
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by lmandel View Post
    Is there an easy way to open a Word Document store the first patient name and then store the patient info in a table - one table per patient, each table with one row and three columns.
    No, there is no easy way to do what you want, because you want to change the order of the field information in the text file.
    That being said, since your data is in the same order all the time, you could write a VBA routine to reorder the information in Excel, so that you could copy and paste into Word.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Quote Originally Posted by lmandel View Post
    Is there an easy way to open a Word Document store the first patient name and then store the patient info in a table - one table per patient, each table with one row and three columns. And then repeat the pattern for each patient in the same file. End result is one file with one 'header' row and one table per patient. (note that the bolded titles in the Word file are the column headers in the .csv file.

    Thanks!

    Larry
    Larry,

    The short answer is NO...sorry. What you want can be accomplished with some VBA programming but the formatting you require to parse the single line per patient into two different cells of a table and each patient into a different table with a header will require some programming.

    RG
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. #4
    New Lounger
    Join Date
    May 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Larry,

    From the forum/lounge in which you have posted your question, I'm guessing that the .csv file is an export from an Excel spreadsheet? Do you have access to the original Excel file from which the .csv was exported? If yes, then you should be able to construct the tables within this excel file from the raw data, using some formulae. If not, then you will first need to import the .csv file into an Excel file. Once you have the tables in Excel, putting them into Word will be a simple copy and paste (which could be automated). The only difficulty I can see is that you have a mixture of bold and plain fonts in some of the cells of your table. With Excel formulae it is not possible to switch between bold and plain fonts within a cell, mixing the fonts can be achieved using VBA macros.

    I've made a stab at setting up the formulae in the attached Excel workbook. Sheet "Raw" is the raw data, in the attachment I set up the raw data by reading in from the .txt (.csv) file you provided. While doing this I found that some of the data in the text file is not in accord with some of the table entries in the Word document. I've also produced a VBA macro to do the bold formatting and to select the range which holds the report, ready to be copied and pasted into word. To run the macro just click on the button "Report" on sheet "Raw".

    Hope this helps,

    RAK.
    Attached Files Attached Files

  5. #5
    New Lounger
    Join Date
    Jun 2010
    Location
    Birmingham, UK
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Larry

    Do you have Microsoft Access? Your csv file would import straight into a table in Access without problems (although Disch Date appears to be missing in the sample provided) and the output could be produced in a simple Access report or, if you must have it in Word, via a Word mail merge. No VBA required.

    David

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by lmandel View Post
    We download a report with hospital patient information every morning in .CSV format - see attached file (I had to change the file type to .txt to upload - original file extension is .csv) - and need to convert the data into a Word file with the data in tables as shown in the attached Word document. Note - examples have fictional data. I know how to store data in a text file. Is there an easy way to open a Word Document store the first patient name and then store the patient info in a table - one table per patient, each table with one row and three columns. And then repeat the pattern for each patient in the same file. End result is one file with one 'header' row and one table per patient. (note that the bolded titles in the Word file are the column headers in the .csv file.

    Thanks!

    Larry
    Hi Larry,

    You could do this quite easily via a Catalog/Directory mailmerge in Word, using the raw txt/csv file as the data source. Basically all you need to do is to create the mailmerge main document with a line for the patient name, followed by a 1-row, 3-column table for the other data. When you execute the row, Word will then generate the desired layout from the data.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Good catch Paul - I had my blinders on.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •