shenwei356 / csvtk

A cross-platform, efficient and practical CSV/TSV toolkit in Golang
http://bioinf.shenwei.me/csvtk
MIT License
999 stars 84 forks source link

Respect input csv format modifiers similarly to when manually importing a CSV to excel #214

Closed ColinHinesTHIG closed 1 year ago

ColinHinesTHIG commented 1 year ago

Prerequisites

Describe your issue

Hello,

I am trying to force columns to be read as text using the formatting described here: https://superuser.com/questions/318420/formatting-a-comma-delimited-csv-to-force-excel-to-interpret-value-as-a-string

Specifically, I would like items formatted with "=""data""" to be seen as when opened with excel.

When i attempt to load a test file, the error I get is: [ERRO] parse error on line 2, column 898: extraneous or missing " in quoted-field

Please use the following two lines and put them in 2 respective files named test-1.tsv and test-2.tsv --

Fxxxd   Fxxxd   Rxcxxpt Dxtx    NAIC Numbxr     Polxcy Numbxr   Rxxson for Trxnsxctxon  Polxcy Effxctxvx Dxtx   Polxcy Expxrxtxon Dxtx  Polxcy Txrm xn months   HO Fxxxd        Trxnsxctxon Effxctxvx Dxtx   Lxst Nxmx;Insurxd Nxmx or Compxny Nxmx  Insurxd/Compxny Mxxlxng Strxxt Addrxss  Insurxd Mxxlxng Town    Insurxd Mxxlxng Stxtx   Insurxd Mxxlxng country Insurxd Mxxlxng Zxp     Insurxd Locxtxon Addrxss (xf dxffxrxnt)      Insurxd Locxtxon Town   Insurxd Locxtxon Stxtx  Insurxd Locxtxon Country        Insurxd Locxtxon Zxp    Lxgxl Dxscrxptxon       Lxxnholdxr Nxmx Lxxnholdxr Nxmx lxnx 2       Lxnxholdxr Addrxss      Lxxnholdxr Town Lxxnholdxr Stxtx        Lxrnholdxr Zxp  Loxn ID Mortgxgx Typx (xst,2nd,xtc)     Covxrxgx A Lxmxt        Covxrxgx B Lxmxt        Rxsxrvxd        Rxsxrvxd     All Pxrxls Dxductxblx   Wxnd Dxductxblx Cxncxllxtxon Rxxson     Agxncy Nxmx     Agxncy Codx     Agxncy Addrxss  Agxncy Town     Agxncy Stxtx    Agxncy Country  Agxncy Zxp      Agxncy Phonx Numbxr  Endorsxmxnts x  Endorsxmxnts Stxtx x    Endorsxmxnts 2  Endorsxmxnts Stxtx 2    Endorsxmxnts 3  Endorsxmxnts Stxtx 3    Prxmxum Amount  Incrxxsxd Prxmxum Amount        Rxmxttxncx Addrxss  Rxmxttxncx Town  Rxmxttxncx Stxtx        Rxmxttxncx Zxp  Rxmxttxncx Country      Rxmxttxncx Phonx        Sxnkholx Covxrxgx Exclusxon?    Wxnd Covxrxgx Exclusxon?        Flood Covxrxgx Exclusxon?   Fxxxd (#)
"=""x"""        "=""L5x77"""    "=""xx2x2x23""" "=""x2538"""    "=""Pxxxx4x6x2 """      "=""L"""        "=""xxx82x22""" "=""xxx82x23""" "=""x2"""       "=""HO"""       "=""xxx42x23""" "=""Jxlloh,Ishbu """ "=""x35x4 Wwwww St """    "=""Rxvxrvxxw """       "=""FL"""       "=""USA"""      "=""33579 """   "="" """        "="" """        "="" """        "="" """        "="" """    "=""x35x4 www St,Rxvxrvxxw """   "=""Sunny """   "="" """        "=""PO Box 0xxx39 """   "=""Txmpx """   "=""FL"""       "=""3368x """   "=""x97385 """  "=""xst"""      "=""xx28xxxx"""      "=""xxxx4x5x""" "="" """        "="" """        "=""xxxx """    "=""x.x2 """    "=""Non-Pxymxnt """     "=""Lxxncy, LLC """    "=""PF9xxD""" "=""4xx Stx 55x"""        "=""vxng """  "=""TX"""       "=""USA"""      "=""75x39 """   "=""8xx235x339 """      "="" """        "="" """        "="" """        "="" """        "="" """        "="" """     "=""xxxxx.xx""" "=""xxxxx.xx""" "="" """        "="" """        "="" """        "="" """        "="" """        "="" """        "="" """        "="" """        "=""x"""        "=""#""" 

and then run

csvtk -t csv2xlsx test-*.tsv -o test-X.xlsx

I've tried this with tabs and pipes as the delimiter

shenwei356 commented 1 year ago

Try adding -l.