[CSVUtil] FieldDelimiter

Forge Component
(21)
Published on 2017-10-09 by Wei Zhu
21 votes
Published on 2017-10-09 by Wei Zhu

Is there anyway to have no FieldDelimiter when setting up the CSV export config. I am trying to export a Recordlist to a file without any additional text formatting and setting the FieldDelimiter to "" still adds commas.


Thanks

Hello Ali Maladwala,

In the extension's code, in MssExportRecordList2CSV, it only sets your delimiter if you provide one:

CsvConfig config = new CsvConfig();
if (!string.IsNullOrEmpty(ssConfig.ssSTCSVExportConfig.ssFieldDelimiter))
    config.Separator = ssConfig.ssSTCSVExportConfig.ssFieldDelimiter[0];

This is why it still adds the commas when you have an empty delimiter.  You could try updating the C# code to remove the empty check, though I am not sure if the included CSV library will override it or not.

The CSVUtil is probably not the best component for your use case, as your use case is not to produce a CSV.  Is it safe to assume your goal is simply to write a record to a flat file with a newline between items?

Craig St. Jean wrote:

Hello Ali Maladwala,

In the extension's code, in MssExportRecordList2CSV, it only sets your delimiter if you provide one:

CsvConfig config = new CsvConfig();
if (!string.IsNullOrEmpty(ssConfig.ssSTCSVExportConfig.ssFieldDelimiter))
    config.Separator = ssConfig.ssSTCSVExportConfig.ssFieldDelimiter[0];

This is why it still adds the commas when you have an empty delimiter.  You could try updating the C# code to remove the empty check, though I am not sure if the included CSV library will override it or not.

The CSVUtil is probably not the best component for your use case, as your use case is not to produce a CSV.  Is it safe to assume your goal is simply to write a record to a flat file with a newline between items?

Hello Craig St. Jean,

My use case is writing a record list to a flat file with a new line between records. Each record is written without delimiters (the record fields have a known fixed character width and have to remain that way). Is there a generic way to flatten a record to a string in Outsystems(like a toString() override), or would I have to write an extension that will handle my specific Entity types?


Thanks,

Ali


Solution

Hi Ali


You can find following code in MssExportRecordList2CSV

  sb.Append(config.Separator);

Just delete it.


Regards

Wei




Solution