Forum Discussion

Maria Baker's avatar
Maria Baker
Copper Contributor
Jul 16, 2020
Solved

Need to convert a text file to Excel - not the typical comma delineated file

I have a text file that needs to be converted to Excel however the text is grouped in a fashion that Excel doesn't not convert into columns but exactly as it appears in the text file.  The text content looks like this.  I added an underscore before 'name' to differenciate each group of text.  How can I import to Excel where the text before each : becomes the column heading?

_name: All Company
id: 0
type: internal
privacy_setting: public
state: active
approximate_messages_count: 6
last_message_at: 2014-06-12 09:52:27.259000062 +00:00
o365_connected: false
group_admins: All Yammer Verified admins
member_counts:
internal: 24565
external: 0
uploaded_file_counts:
yammer_files: 0
sharepoint_files: 0
66069:
__name: Marine Matter
id: 66069
type: internal
privacy_setting: public
state: deleted
approximate_messages_count: 70
last_message_at: 2015-10-30 08:31:43.069999000 Z
o365_connected: false
group_admins:
with_o365_creation_rights: []
without_o365_creation_rights: []
member_counts:
internal: 0
external: 0
uploaded_file_counts:
yammer_files: 0
sharepoint_files: 0
89528:
_name: Summers Lab
id: 89528
type: internal
privacy_setting: public
state: deleted
approximate_messages_count: 10
last_message_at: 2012-10-01 11:00:22.418401000 Z
o365_connected: false
group_admins:
with_o365_creation_rights: []
without_o365_creation_rights: []
member_counts:
internal: 0
external: 0
uploaded_file_counts:
yammer_files: 0
sharepoint_files: 0
89758:
_name: Pilot Group
id: 89758
type: internal
privacy_setting: public
state: active
approximate_messages_count: 16
last_message_at: 2011-07-04 09:46:24.989397000 Z
o365_connected: false
group_admins:
with_o365_creation_rights: []
without_o365_creation_rights: []
member_counts:
internal: 0
external: 0
uploaded_file_counts:
yammer_files: 1
sharepoint_files: 0
90435:

  • Maria Baker 

    IMHO, it's not necessary to change delimiters, in general it's not necessary to make any changes in your text file. For the delimiters you may use split only on left most delimiter, that won't affect the dates. 

     

    Variant of layout as TheAntony  suggested is in TextTransformTwo query attached.

15 Replies

  • Smith_J's avatar
    Smith_J
    Brass Contributor

    You can import data from a text file into an existing worksheet.

    On the Data tab, in the Get & Transform Data group, click From Text/CSV.

    In the Import Data dialog box, locate and double-click the text file that you want to import, and click Import.

    In the preview dialog box, you have several options:

    Select Load if you want to load the data directly to a new worksheet.

    Alternatively, select Load to if you want to load the data to a table, PivotTable/PivotChart, an existing/new Excel worksheet, or simply create a connection. You also have the choice of adding your data to the Data Model.

    Select Transform Data if you want to load the data to Power Query, and edit it before bringing it to Excel.

    • Maria Baker's avatar
      Maria Baker
      Copper Contributor

      Smith_J  Thank you for the input.  This is the process I started with - the issue I'm having is understanding how to manipulate the data in power query into multiple columns instead of one column.

      Thank you

  • TheAntony's avatar
    TheAntony
    Iron Contributor

    Maria Baker , I used Power Query to accomplish this. I copied your sample into a text file (attached). I changed the delimiter from ":" to ";" since there were dates in the data that used ":". To use this change the location of the source text file in the source table. The processed data will be in the Output tab.

    • Maria Baker's avatar
      Maria Baker
      Copper Contributor

      TheAntony Thank you.  I'm not familiar with power queries...so I'm stuck on this part, "change the location of the source text file in the source table."  Where do I change this?

      Thank you

      MB

      • TheAntony's avatar
        TheAntony
        Iron Contributor

        Maria Baker 

        •  Download the 2 files I uploaded to your local drive
        • Open the Excel file - "Test Power Query.xlsx"
        • It will open up in the tab named Source
        • Change the File Path in the cell A2 from "C:\Users\dgant\Downloads\test.csv" to the file path of the test.csv file that you down loaded. 
        • Go to the tab named "Output" that shows you the output of PQ
        • Save the xlsx file
        • Open test.csv and add more records (making the appropriate changes I mentioned - using ; as the delimiter instead of :_
        • Save test.csv
        • Hit Data->Refresh All in the Excel file to see the output table updated with the info you put in the csv file

         

        Or you can use SergeiBaklan 's solution. Let us know how it goes.

         

         

         

Resources