|
#1
|
|||
|
|||
|
Sorting .txt data to .csv
Hi all this has been mind boggling for me and have had to go in search for much needed help.
![]() I want to sort txt data automatically to be used with a .csv file so i can use it to create a spreadsheet in openoffice (Calc). I would do it manually, but I will be using vast amounts of data. I need help with either pointing me in the direction of a useful application or even a simple snippet of coding for a script. Here is an example of just 1 line of the data: Code:
15 Lion Fan City 3/1/2007 8:14:48 PM 14,893.700 696.71 2,162.27 251.01 So in summary that 1 line would end up like this: Code:
15# Lion Fan City# 3/1/2007# 8:14:48# 14,893.700# 696.71# 2,162.27# 251.01# Any help on this would be very much appreciated. |
|
#2
|
||||
|
||||
|
I have made an program in java that will do this for you. It has been uploaded here. To run it, save it to its own directory, create a COPY of the txt file you need as an input and call it infile.txt create another txt file called outfile.txt. Put both these files in the same directory as the program you downloaded. Then double click the downloaded file. Nothing will look to be happening but after a while, the outfile will update with all the information.
You will need java installed to run this program The lines will need to be exactly in the same layout as the one you posted All the numbers at the end of the line will need to have decimal points in them. If they don't have decimal points in them post here and I will change the program If you don't want to download the program in case it has a virus etc then you could send me the file you want changed and I will send the completed version back. Last edited by Chriz; July 21st, 2007 at 09:44 PM. Reason: I forgot to put the link to the program in |
|
#3
|
||||
|
||||
|
Hey chriz, nice bit of code - do you mind if I pinch it and have a play - I occsaionaly need to perform bizzare sorts from odd output strings. Ever moved from a "firstname, lastname" domain to a "lastname, firstname" domain and tried to copy the security groups?
Nightmare! hacking this baby would've saved me hours.
|
|
#4
|
||||
|
||||
|
nope. I don't mind a bit. I don't know that it would be that useful in the situation you have named as this just looks for certain patterns and writes the data in the order it was given to it. To alter the data order you would have to store each String in a variable or something before writing it.
|
|
#5
|
||||
|
||||
|
Cheers, I'll have a play and let you know when I make a monumental hash of it
|
|
#6
|
|||
|
|||
|
Brilliant, Thank-you!
There is one small problem. It does not copy the names (Lion Fan City) to the outfile.txt I also forgot to add a ')' in the data line and one last number at the end as highlighted in red: Data lines are exactly like this: Code:
1) X.G.A. 2/24/2007 5:05:34 PM 27,857.403 1,580.36 3,999.99 354.92 50 2) Magi Nation 2/25/2007 7:33:58 PM 27,671.491 1,019.95 4,779.99 341.98 7 It there any way to customise this script? Last edited by Chillers; July 23rd, 2007 at 05:17 PM. |
|
#7
|
||||
|
||||
|
Ok the changes you have specified have been made. The program is uploaded here http://www.megaupload.com/?d=O3RXNJ14
|
|
#8
|
|||
|
|||
|
Works great! No problems. Thankyou very much!
|
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 05:42 PM.
[
RSS ]





Nightmare! hacking this baby would've saved me hours.




