Currently, when I import the CSV file line by line with String.split(",")
if there is a line that looks like "foo,,bar,,fizz,,,"
the method returns an array of length 5, which looks like ["foo", "", "bar, "", "fizz"]
. How do I get the method to return an array of length 8 being ["foo", "", "bar", "", "fizz, "", "", ""]
?
Description. The Import-Csv cmdlet creates table-like custom objects from the items in CSV files. Each column in the CSV file becomes a property of the custom object and the items in rows become the property values. Import-Csv works on any CSV file, including files that are generated by the Export-Csv cmdlet.
There is another overload of split
that achieves that:
string.split(",", -1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With