How to convert xlsx to csv
Hi ommunity,
I am downloading an Excel xlsx from the web with the below method and saving it as xlsx, how do I convert and save xlsx as csv?
ClassMethod DownloadFileUrl()
{
Set httprequest = ##class(%Net.HttpRequest).%New()
Set httprequest.Server = "www.health.gov.za"
Set httprequest.SSLConfiguration = "SSL_OAUTH_Client"
Do httprequest.Get("/wp-content/uploads/2021/04/ICD-10_MIT_2021_Excel_16-March_2021.xlsx")
write httprequest.HttpResponse.StatusLine
Set stream=##class(%FileBinaryStream).%New()
Set stream.Filename="/home/Data/March_2021.xlsx"
Write stream.CopyFrom(httprequest.HttpResponse.Data)
Write stream.%Save()
Write stream.%Close()
}
Product version: IRIS 2020.2
There are some open source tools that can convert from XLSX to CSV. You could call out to these from your ObjectScript code:
https://csvkit.readthedocs.io/en/latest/tutorial/1_getting_started.html#...
https://stackoverflow.com/questions/10557360/convert-xlsx-to-csv-in-linu...
Use LibreOffice from IRIS or (if you only need the data) Apache POI.
This is a good free site ive used, hope it helps.
Online XLSX to CSV Converter | Free GroupDocs Apps