Search code examples
libreoffice-calc

convert csv to dbase in LibreOffice in headless mode


I can convert a csv file with dates to dbase in LibreOffice in regular mode. H_beg date and H_end_date work perfectly.

dbview thexport.dbf
H event id : 210721001
H name     : CCCR WEEK NIGHT 072121
H tot sect : 1
H beg date : 20210721
H end date : 20210721
H rcv date : 
H ent date : 
H aff id   : A6000220
H city     : ROCHESTER
H state    : NY
H zipcode  : 14621
H country  : USA
H sendcros : N
H scholast : N
H secrec01 : 0

But if try to automate the operation in headless (batch) mode, the date fields are blank!

bash script: libreoffice --headless --invisible --convert-to dbf thexport.csv

dbview thexport.dbf
H event id : 210721001
H name     : CCCR WEEK NIGHT 072121
H tot sect : 1
H beg date : 
H end date : 
H rcv date : 
H ent date : 
H aff id   : A6000220
H city     : ROCHESTER
H state    : NY
H zipcode  : 14621
H country  : USA
H sendcros : N
H scholast : N
H secrec01 : 0

Any way to fix this?


Solution

  • sudo apt install unoconv
    
    #!/bin/bash 
    cd /wherever/your_files_are/
    unoconv thexport.csv thexport.dbf
    unoconv tsexport.csv tsexport.dbf
    unoconv tdexport.csv tdexport.dbf