With Calc, you don’t need any pre-processing. It can import all kinds of reasonably valid csv.
How to import csv into Calc by macro:
- Open your specific flavor of csv manually with locale, char set and all options properly set.
- Run this code against the active csv document:
Sub showFilterOptions()
Dim args(),i%
args() = StarDesktop.CurrentComponent.getArgs()
for i = 0 to uBound(Args())
if args(i).Name = "FilterOptions" then inputbox args(i).Name,"",cStr(args(i).value)
next
End Sub
- Copy the FilterOptions into your code which may be as simple as this:
dim p(1) as new com.sun.star.beans.PropertyValue
p(0).Name = "FilterName"
p(0).Value = "Text - txt - csv (StarCalc)"
p(1).Name = "FilterOptions"
p(1).Value = "your_specific_filter_options_string"
doc = StarDesktop.loadComponentFromURL(convertToURL(sysPath), "_blank", 0, p())