xls2csv delimiter
i found a great tool xls2csv to convert MS excel sheets to csv files which I'm using to insert into a database.
I'm having a slight problem with one excel sheet which includes commas in the fields. Because of this, the CSV file is damaged and is not reliable to be inserted into a database. So the solution is to change the delimiter in xls2csv. According to man: Code:
xls2csv(1) xls2csv(1) Code:
NG:~# xls2csv Code:
NG:~/downloads# xls2csv -x "test.xls" -w "Sheet1" -c "test.csv" -cchar "~" I'm not sure what i can do next to make it work. is there is a way to change the default delimiter for xls2char rather trying the above? Any input will be highly regarded. |
Quote:
--- rod. |
Doing a quick search there appears to be different options between the different versions. One version uses -c for a delimiter character and the other uses -c for the output filename.
http://www.linuxmanpages.com/man1/xls2csv.1.php vs http://search.cpan.org/~ken/xls2csv-1.06/script/xls2csv The first link shows -cchar which IMHO means that -c is the option and not -cchar. Your version shows -c is the output file name. Not sure what your options are at this point. Might be able to use sed to fix the data. |
thanks michaelk for pointing me on the right direction. fixing the problem with sed could be done if was to conver one sheet. But it's going to be very time consuming if I wanted to examine 5 excel sheets a day and figure what a sed command that will do for each one. The excel sheets are different will be received daily and must be converted to CSV then inserted in SQL.
i searched all over the place for xls2csv 0.93.3but i couldn't find it. CPAN doesn't have it and i don't know of a site that have old perl modules. Any ideas or should i just search for another utility? |
Might just want to look for another utility. I found this:
http://wizard.ae.krakow.pl/~jb/xls2txt/ |
works
I found this guy somewhere and he works beautifully. The utility requires Spreadsheet::ParseExcel.
Code:
#!/usr/bin/perl |
Hi,
not sure whether you're still looking for an answer, but I ran ingto the very same issue - and was able to solve it. I've pulled down version 0.7.3 from GitHub and here you are able to specify the delimiter via the "-d <delim>" Option, e.g. to set the delimiter to semicolon you would use: xlsx2csv --ignoreempty --skipemptycolumns --sheet 7 -d ";" Mappings.xlsx Mappings.csv Hope that helps! Cheers |
I thought maybe Excel would work, because it has an export function. The other way to do it is to export to text of fixed field length, and then specify the size of each field for the import.
|
All times are GMT -5. The time now is 03:41 PM. |