csvChangeDelimitationCharacter

Description: This method is used to replace the comma delimiter with a delimiter of your choice. Any valid ASCII character can be specified (1-254). For example if we swapped the comma with the pound symbol "#" (ASCII 35) the file before applying this process looks like:

Data1,Data2,Data3,Data4

Data1,Data2,Data3,Data4

After applying this process it looks like:

Data1#Data2#Data3#Data4

Data1#Data2#Data3#Data4

Parameters:

csvChangeDelimitationCharacter(sInputFile As String, sOutputFile As String, sChar As String) As Long

Parameter

Meaning

sPathOriginal

CSV file to modify.

sPathTarget

Can be same as sPathOriginal in which case sPathOriginal will be overwritten. If a different name is specified, XLSConverterX will create a new file.

sChar

Character to replace the comma as delimiter.

Return Values:

0: Success 

-2: "Unable to open or save to target file. Could be a sharing violation, or invalid file type. 

-3: "Unable to open original file. Check file format. Could be a sharing violation. 

-201: "Shareware has expired" 

Example Code:

This VB function is representative of how the component may be used with any of the csv special processes. The value returned by the function may then be further evaluated, as necessary.

Private Function BeginCSVSpecialProcess(lngProcess As Long, _

strSourceFile As String, _

strTargetFile As String, _

strNewChar As String, _

strRowsToUse As String, _

strColsToUse As String) As Long

Dim lngConvResult As Long

 'call the appropriate method from the component with the

 'necessary arguments

Select Case (lngProcess)

Case SP_CSV_SURROUND_WITH_QUOTES

lngConvResult = XLSConv1.csvEncaseEachFieldWithQuotes

    (strSourceFile, strTargetFile)

Case SP_CSV_PAD_WITH_SPACES

lngConvResult = XLSConv1.csvPadWithSpaces(strSourceFile,

strTargetFile)

Case SP_CSV_CHANGE_DELIMITER

lngConvResult = XLSConv1.csvChangeDelimitationCharacter

(strSourceFile, strTargetFile, strNewChar)

Case SP_CSV_REMOVE_EMPTY_LINES

lngConvResult = XLSConv1.csvRemoveEmptyLines(strSourceFile,

strTargetFile)

Case SP_CSV_INCLUDE_ROWS

lngConvResult = XLSConv1.csvCropCSVFileRows(strSourceFile,

strTargetFile, strRowsToUse)

Case SP_CSV_INCLUDE_COLS

lngConvResult = XLSConv1.csvCropCSVFileCols(strSourceFile,

strTargetFile, strColsToUse)

Case SP_CSV_REMOVE_CTL_CHARS

lngConvResult = XLSConv1.csvRemoveControlCharactersFromFile

(strSourceFile, strTargetFile)

Case SP_CSV_TRIM_EXCESS_COMMAS

lngConvResult = XLSConv1.csvTrimCSVFile(strSourceFile,

strTargetFile)

End Select

 'if the component returns 0 (success) do a further check that

 'the file was created

If (lngConvResult = 0) Then 

If (FileExists(strTargetFile) = False) Then

lngConvResult = -100

End If

End If

 'assign an error code, if applicable

Select Case (lngConvResult)

Case -2

strErr = "Unable to open or save to target file. Could be

a sharing violation, or invalid file type."

Case -3

strErr = "Unable to open original file. Check file format.

Could be a sharing violation."

Case -100

strErr = "File does not exist."

End Select

 'function value returned to caller for additional evaluation

BeginCSVSpecialProcess = lngConvResult

End Function