So, who want's to help me format a .csv? It'll be fun, promise!
well, maybe not. I have a 7mb .csv that is in a completely unusable format. Right now it looks like this:
Code:
AAXJ,07/21/2010,53.9900 Code:
01/01/09, AAAA, AAAB, AAAC and so forth |
I think you are going to have to explain further as:
Quote:
Quote:
|
Quote:
Date, AAXJ, ACWI, ACWX, should be what the top line says. |
Hi,
Your desired end-result is still a bit vague: Quote:
Quote:
If that is the case and your example input from post #1 is relevant: Code:
#!/bin/bash Code:
$ ./csv.reformat.sh 1) I removed the spaces after the comma. They are probably not needed (the output being a csv file too) 2) There is a trailing , after each line. Probably not a problem, but you easily remove them by changing the last line ( }' ) with this: }' | sed 's/,$//' Hope this helps. BTW: I enlarged the input file for better testing, that's why the results won't match the data given in post #1. |
Thanks a bunch man, but this is not QUITE what I need. This is so close, and I think I should be able to figure this out on my own, but I'm just not able to. Here is what the final output has to look like.
Code:
Date,AAXJ,ACWI,ACWX |
You could try something like:
Code:
#!/usr/bin/awk -f |
Hi,
I'm still willing to help you out, but you do need to be precise..... You say this is the desired output, which looks weird to be honest: Quote:
Quote:
Quote:
Quote:
I do have a workable solution, if you are able to add an extra line to the 7 Mb csv file you have. This is needed otherwise the last line of input is not taken into account. I need a unique End-Of-File line. I don't think it is too hard to add to your csv file: echo "ZZZZ,99/99/9999,99.9999" >> file.csv (Mind the >>, 2 of them, not 1!!!). Code:
#!/bin/bash Code:
$ cat csv.reformat.infile Hope this helps. |
@grail: Just noticed your post. Its a beauty!
|
Thanks ya'll these are absolutely brilliant. I think I have this under control now.
|
All times are GMT -5. The time now is 08:25 PM. |