maihabunash
maihabunash

Reputation: 1702

xls2csv + disable empty spaces from the XLS

I use the xls2csv binary in order to translate XLS doc to CSV in my linux red-hat machine,

in some cases the XLS doc have space before word or after word

example of XLS file ( word3 have one space on the right side )

 word1 word2 "word3 "
 word1 word2 "word3 "
 word1 word2 "word3 "

after I runs the xls2csv

as:

  xls2csv -x "1252spreadsheet.xls" -b WINDOWS-1252 -c "ut8csvfile.csv" -a UTF-8 ) 

I notice that word3 in the csv doc have the same space on word3 as in XLS ( "word3 " )

please advice how to configure the xls2csv binary in order to disable empty spaces???? from the XLS doc , so I will get the CSV without empty spaces ?

FROM XLS2CSV MAN PAGE:

 man xls2csv
 XLS2CSV(1)            User Contributed Perl Documentation           XLS2CSV(1)

 NAME
       xls2csv - A script that recodes a spreadsheetâs charset and saves as CSV.

    DESCRIPTION
        This script will recode a spreadsheet into a different character set and output     the recoded data as a csv file.

          The script came about after many headaches from dealing with Excel   spreadsheets from clients that were being
       received in various character sets.

  OPTIONS
           -x     : filename of the source spreadsheet
           -b     : the character set the source spreadsheet is in (before)
           -c     : the filename to save the generated csv file as
           -a     : the character set the csv file should be converted to (after)
           -q     : quiet mode
           -s     : print a list of supported character sets
           -h     : print help message
           -v     : get version information
           -W     : list worksheets in the spreadsheet specified by -x
           -w     : specify the worksheet name to convert (defaults to the first worksheet)
           -n     : specify the worksheet number to convert (you cannot use this option with -w)
           -f     : force the worsheet to be fully parsed. This disables the feature that skips rows when the first cell is blk

Upvotes: 0

Views: 703

Answers (1)

Ron Bergin
Ron Bergin

Reputation: 1068

IMO, it sounds like you're using the wrong tool. Maybe you should write a script that uses Spreadsheet::ParseExcel to read/parse the xls file and then apply whatever field reformatting that is needed. Once that is done use Text::CSV_XS to output the csv data.

EDIT: I meant to post that as a comment, but I guess it could also be taken as an answer.

Upvotes: 1

Related Questions