Jump to content

long text file conversion to spreadsheet/CSV


drrehak
 Share

Recommended Posts

hi, would love to pick your brains on this. I just cant get my data the way I need it.

text file is:

#id:

201

#name:

Kevin

#job:

Nerd

#id:

202

#name:

Homer

#job:

Nuclear Engineer

How do I rewrite this to:

201, Kevin, Nerd

202, Homer, Nuclear Engineer

I have tried using openoffice transpose, but the list of fields is too long. I know I need to use an array, but need some guidance. thanks in advance!

-Kevin

Link to comment
Share on other sites

Start with _FileReadToArray(). Then walk through the array with a For/Next loop.

- If the current index $n is "#id" then start a new record line and the next index $n+1 is the first field, followed by a comma.

- If the current index is blank ContinueLoop to the next line.

- If the current index is "#name" then the next index is the second field to add to the line.

- If the current index is "#job" then the next index is the last field, FileWriteLine() to the output file.

You can do this. Take a shot at it and post your code for more help if you get stuck.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

thanks PSalty. that worked. I just had to step through the array. The problem is I have quite a few IF statements to find what I am looking for. Its a huge data file and I am capturing about 10 fields. Some of the fields are multiline too. that made it a little tricky.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...