2

I have got ASCII files and want to convert them into maybe excel or tab/csv delimited text file. The file is a table with field name and field attributes. It also includes index name, table name and field(s) to index if required depending on the software. I don't think it is necessary to think of this. Well, field name and field attributes are enough, I hope so. I just want the information hidden inside. Can you all experts help me to get this done.

The lines are something like this:

10000001$"WORD" WORD$10001890$$$$495.7$$$N$$
10000002$11-word-word word$10000002$$$$$$$Y$$
10000003$11-word word word$10033315$0413004$$$$$$N$$
10000004$11-word word word$10033315$$$$$$$Y$017701$
naught101
  • 18,687
  • 19
  • 90
  • 138
Sammed
  • 23
  • 1
  • 3
  • 3
    1. ASCII is iin fact human readable. 2. Paste two or three lines of the file in question – Mchl Jul 11 '11 at 15:43
  • also, operating system. If you're under windows, a one-line bash hack is probably not going to cut it :) – cdegroot Jul 11 '11 at 15:44
  • could you post the beginning of your file, so we can take a look at the lines until the data begin ? – woliveirajr Jul 11 '11 at 15:46
  • Thank you experts for your comments. Well, @ mchl @ fvu and @ woliveirajr I can't really paste the initial lines of the file as it is a authorized file. – Sammed Jul 11 '11 at 16:02

1 Answers1

1

The general answer, before knowing your ascii file in details, operating system, and so on, would be:

1 - cut the top n-lines, that containg the information you don't want. Leave the filds names, if you want to.

2 - check if the fields are separated by a common character, for example, one comma ,

3 - import the file inside a spreadsheet program, like Excel or OpenOffice Calc. In OOCalc, choose to import the file, then select the correct separating character

that's all.

woliveirajr
  • 9,433
  • 1
  • 39
  • 49
  • Thank you for your reply. Well, to check the separator in the file how do I open it. It has the .asc extension and what program should I use to open it. I can't really show the format here as it is licensed file. – Sammed Jul 11 '11 at 15:59
  • you can try to change it's name to .txt and open using notepad, for example... or rename it to .csv and open with openoffice, and see how it will look like – woliveirajr Jul 11 '11 at 16:03
  • The lines are something like this 10000001$"WORD" WORD$10001890$$$$495.7$$$N$$ "line break" 10000002$11-word-word word$10000002$$$$$$$Y$$ "line break" 10000003$11-word word word$10033315$0413004$$$$$$N$$ "line break" 10000004$11-word word word$10033315$$$$$$$Y$017701$ "line break". I hope you get this. Whereever I have written "line break" means that the next statement is on next line. Thank you. – Sammed Jul 11 '11 at 16:24
  • @Sammed: ok , these are the first lines, or the data you want to use? – woliveirajr Jul 11 '11 at 16:32
  • @Sammed: and it seems that you just have to choose to use $ as the field separator, and you'd have your results. Just need to know how many lines to skip in the beggining – woliveirajr Jul 11 '11 at 16:43
  • These are the first few lines as well as the data. Because the whole file contains the same thing in a column. The detail says that it has 11 field names and the attributes are long integer(not null), char(not null), long integer, char, long integer, rest 6 fields are char. I have replaced the actual words in the file by 'word'. Well, I don't think I have to replace anything. Because as I said the file starts with these lines and continues the same till the end – Sammed Jul 11 '11 at 16:45
  • @Sammed: perfect. Take a look and see that the `$` divides your input in 11 fields, so just rename your file to `.csv`, open it with openoffice calc, select `$` as the field separator, and you'll have your values, each field maped to one column. – woliveirajr Jul 11 '11 at 16:51