xls2csv +禁用从XLS空的空间 [英] xls2csv + disable empty spaces from the XLS

查看:192
本文介绍了xls2csv +禁用从XLS空的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 xls2csv 二进制要想在我的Linux红色帽子的机器翻译XLS文档以CSV,

在某些情况下,XLS文档字之前或单词后有空格

例如XLS文件(WORD3对右侧有一个空格)

 字1字词2WORD3
 字词1 WORD2WORD3
 字词1 WORD2WORD3

我运行后,在 xls2csv

为:

  xls2csv -x1252s preadsheet.xls-b WINDOWS-1252 -cut8csvfile.csv-a UTF-8)

我注意到WORD3在CSV DOC对WORD3同一空间中XLS(WORD3)

请指教如何配置的 xls2csv 二进制文件,以禁止空格????从XLS文档,所以我会得到CSV没有空的空间?

FROM XLS2CSV手册页:

 男人xls2csv
 XLS2CSV(1)用户投稿Perl文档XLS2CSV(1) 名称
       xls2csv - 这重新codeS A S $ P $padsheetâs字符集和保存为CSV的脚本。    描述
        该脚本将重新code A S preadsheet成不同的字符集和输出的再codeD数据为CSV文件。          从与Excel US preadsheets处理从,正在客户很多头痛的问题后,该脚本是约
       在各种字符集接收。  OPTIONS
           -x:源极s preadsheet的文件名
           -b:字符集源极s preadsheet是(前)在
           -c:文件名保存生成CSV文件
           -a:设置CSV文件的字符应转换为(后)
           -q:安静模式
           -s:打印支持的字符集列表
           -h:打印帮助信息
           -v:获取版本信息
           -w:由-x指定s preadsheet列表的工作表
           -w:指定的工作表名称(默认为第一个工作表)转换
           -n:指定的工作表数转换(不能使用带有-w此选项)
           -f:强制worsheet被完全处理。这禁用跳过行功能时,第一个单元格是BLK


解决方案

IMO,这听起来像你正在使用错误的工具。也许你应该写一个使用小号preadsheet脚本:: ParseExcel的读/解析xls文件,然后应用领域的任何重新格式化就足够了。一旦做到这一点用文字:: CSV_XS输出CSV数据。

编辑:我的意思后,作为一个评论,但我想它也可以作为一个答案

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

解决方案

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.

这篇关于xls2csv +禁用从XLS空的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆