Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How do I reorganize a single list of data into a CSV in Excel?

I have a long list of data that follows a very exact pattern. Reading it and interpreting it is simple; but, I would like to use a script through the list and create a spreadsheet so that it's easier to work with the data. Your help and scripting skills will be greatly appreciated.

The raw list looks like list:

http://mydomain.com/?1

2.23

1.06

0.45

http://mydomain.com/?2

0.36

1.25

0.21

2.36

http://mydomain.com/?3

0.60

2.30

1.30

I would like to read the list (from the last row up...?) and rewrite the data so that it looks like this (comma separated here... in excel, possible to just move to the prior row's last blank cell):

http://mydomain.com/?1, 2.23, 1.06, 0.45

http://mydomain.com/?2, 0.36, 1.25, 0.21, 2.36

http://mydomain.com/?3, 0.60, 2.30, 1.30

I'm happy to provide more details. I will use and award for any method that gives that final result. Thank you!

Update:

colanth - ty for that but I am looking for a script

CinderBlock - you are brilliant for sure and I like the answer; but, I am looking for the VBA so I can make it portable. No C here : - /

Any VBA thoughts?

Update 2:

Took the long route (as usual!).

Solution I eventually settled for searching and replacing using regular expressions in Textpad:

replace "\n" with ",\n"

then replace ",\nh" with "\nh"

then ",\n" with ","

Opened in Excel text-to-columns > comma separated.

Thanks again!

2 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    If the list is in a text file, it would be easier to do that with a program than an excel macro, e.g., in C it would be:

    char buffer[1000];

    char outline[10000];

    outline[0]=0;

    while (gets(buffer)!=EOF) {

    buffer[strlen(buffer)]=0; /* eliminate newline char */

    if (buffer[0]=='h') {

    if (outline[0]) puts(outline);

    strcpy(outline,buffer);

    }

    else {

    strcat(outline,', ');

    strcat(outline, buffer);

    }

    }

    puts(outline);

    then you pipe the source file into the program, and it streams the output lines all concatenated to stdout.

  • Anonymous
    1 decade ago

    File/Save As .../ Change the Sav as Type (on the bottom of the Save dialog) to CSV. Save the file. It'll be a CSV file.

    If you're using Access as your database, don't even bother - just import the xls file.

Still have questions? Get your answers by asking now.