----------------------------------------------------------------------
--- Knud van Eeden --- 15 February 2008 02:30 pm ---------------------

Computer: Editor: TSE: Comma separated values: How to convert comma separated value files to fixed value files? [CSV]

===

Method:

1. Read your comma separated value data 2 times.

1.1. The first time it calculates the longest line, for each column, and stores this (in an array).

1.2. The second time it puts your comma separated values at that correct maximal position in each column (based on that array values)

===

Steps: Overview:

 1. -E.g. given the following comma separated values

--- cut here: begin --------------------------------------------------
COLUMN1,COLUMN2,COLUMN3,COLUMN4,COLUMN5,COLUMN6 aaaa,bbb,ccccc,ddd,eee,ff dddd,eee,fff,ggg,hhh,iiiiiii jjsasdsfasdfasdfj,kkk,ll,mmmmm,nnnn,oooo
--- cut here: end ---------------------------------------------------- 1. -Highlight the block 2. -Choose as separator a comma , 3. -After running the program that will show a screen output similar to the following: --- cut here: begin --------------------------------------------------
COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 aaaa bbb ccccc ddd eee ff dddd eee fff ggg hhh iiiiiii jjsasdsfasdfasdfj kkk ll mmmmm nnnn oooo
--- cut here: end ---------------------------------------------------- 2. -Another example: --- cut here: begin --------------------------------------------------
ID_REQUEST;DATE_REQUEST;TIME_REQUEST;PRIORITY_REQUEST;VALUE_REQUEST;EMP_REQUEST;EMP_AUTHOR;EMP_PROCESSED 1;01/01/2007 ;14:12:00 ;1 ; 200,00; 10; 20; 40 2;04/01/2007 ;15:12:25 ;2 ; 300,00; 20; 10; 30 3;01/12/2007 ;15:13:25 ;1 ; 200,00; 40; 10; 20 4;01/01/2007 ;16:20:32 ;2 ; 210,00; 10; 20; 40 5;31/12/2007 ;14:20:30 ;3 ; 100,00; 40; 10; 20
--- cut here: end ---------------------------------------------------- 1. -Highlight the block 2. -Choose as separator a semi-colon ; 3. -After running the program that will show a screen output similar to the following: --- cut here: begin --------------------------------------------------
ID_REQUEST DATE_REQUEST TIME_REQUEST PRIORITY_REQUEST VALUE_REQUEST EMP_REQUEST EMP_AUTHOR EMP_PROCESSED 1 01/01/2007 14:12:00 1 200,00 10 20 40 2 04/01/2007 15:12:25 2 300,00 20 10 30 3 01/12/2007 15:13:25 1 200,00 40 10 20 4 01/01/2007 16:20:32 2 210,00 10 20 40 5 31/12/2007 14:20:30 3 100,00 40 10 20
--- cut here: end ---------------------------------------------------- 4. -E.g. create the following program: --- cut here: begin --------------------------------------------------
// filenamemacro=chanblvd.s
--- cut here: end ---------------------------------------------------- --- cut here: begin --------------------------------------------------
// PROC PROCBlockChangeDatabaseConvertCommaSeparatedValueToFixedValueDefault()
--- cut here: end ---------------------------------------------------- --- cut here: begin --------------------------------------------------
FORWARD INTEGER PROC FNArrayGetVariableDimension1I( STRING s1, INTEGER i1 ) FORWARD INTEGER PROC FNArrayGetVariableDimension2I( STRING s1, INTEGER i1, INTEGER i2 ) FORWARD INTEGER PROC FNBlockGetDatabaseLineColumnTotalLineCommaSeparatedValueI( STRING s1, STRING s2 ) FORWARD INTEGER PROC FNBlockGetDatabaseLineTableColumnSeparatorMaxI( STRING s1, STRING s2 ) FORWARD INTEGER PROC FNBlockGetDatabaseRowTotalCommaSeparatedValueI() FORWARD INTEGER PROC FNLineGetDatabaseColumnTotalLineCommaSeparatedValueI( STRING s1, STRING s2 ) FORWARD INTEGER PROC FNLineGetDatabaseSeparatorTotalCommaSeparatedValueI( STRING s1, STRING s2 ) FORWARD INTEGER PROC FNStringGetToIntegerI( STRING s1 ) FORWARD PROC Main() FORWARD PROC PROCArraySetVariableDimension1( STRING s1, INTEGER i1, STRING s2 ) FORWARD PROC PROCArraySetVariableDimension2( STRING s1, INTEGER i1, INTEGER i2, STRING s2 ) FORWARD PROC PROCArraySetVariableResetAllDimension1( STRING s1, INTEGER i1, INTEGER i2 ) FORWARD PROC PROCBlockChangeDatabaseConvertCommaSeparatedValueToFixedValueDefault() FORWARD PROC PROCBlockChangeDatabaseConvert_CommaSeparatedValueToFixedValue( STRING s1, STRING s2, STRING s3 ) FORWARD PROC PROCBlockGetDatabaseColumnWidthMaximumVariable( STRING s1, STRING s2, STRING s3 ) FORWARD STRING PROC FNArrayGetVariableDimension1S( STRING s1, INTEGER i1 ) FORWARD STRING PROC FNArrayGetVariableDimension2S( STRING s1, INTEGER i1, INTEGER i2 ) FORWARD STRING PROC FNStringGetColumnSeparatorArrayMaximumS() FORWARD STRING PROC FNStringGetColumnSeparatorArrayS() // --- MAIN --- // PROC Main() PROCBlockChangeDatabaseConvertCommaSeparatedValueToFixedValueDefault() END <F12> Main() // --- LIBRARY --- // // library: block: change: database: convert: comma: separated: value: to: fixed: value: default <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=chanblvd.s) [<Program>] [<Research>] [kn, ri, sa, 16-02-2008 22:01:15] PROC PROCBlockChangeDatabaseConvertCommaSeparatedValueToFixedValueDefault() // e.g. PROC Main() // e.g. PROCBlockChangeDatabaseConvertCommaSeparatedValueToFixedValueDefault() // e.g. END // e.g. // e.g. <F12> Main() // PROCBlockChangeDatabaseConvert_CommaSeparatedValueToFixedValue( FNStringGetColumnSeparatorArrayS(), FNStringGetColumnSeparatorArrayMaximumS(), "," ) // END // library: block: change: convert: comma: separated: value: to: fixed: value <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=chanblfv.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 01:15:36] PROC PROCBlockChangeDatabaseConvert_CommaSeparatedValueToFixedValue( STRING variableNameArraySA, STRING variableNameMaximumSA, STRING separatorS ) // e.g. PROC Main() // e.g. STRING s1[255] = FNStringGetInitializeNewStringS() // e.g. s1 = FNStringGetInputS( "<info>: separatorS = ", "," ) // e.g. IF FNKeyCheckPressEscapeB( s1 ) RETURN() ENDIF // e.g. PROCBlockChangeDatabaseConvert_CommaSeparatedValueToFixedValue( FNStringGetColumnSeparatorArrayS(), FNStringGetColumnSeparatorArrayMaximumS(), s1 ) // e.g. END // e.g. // e.g. <F12> Main() // // example // // before: // /* COLUMN1,COLUMN2,COLUMN3,COLUMN4,COLUMN5,COLUMN6 aaaa,bbb,ccccc,ddd,eee,ff dddd,eee,fff,ggg,hhh,iiiiiii jjsasdsfasdfasdfj,kkk,ll,mmmmm,nnnn,oooo */ // // after: // /* COLUMN1 COLUMN2 COLUMN3 COLUMN4 COLUMN5 COLUMN6 aaaa bbb ccccc ddd eee ff dddd eee fff ggg hhh iiiiiii jjsasdsfasdfasdfj kkk ll mmmmm nnnn oooo */ // INTEGER rowI = 0 // INTEGER rowMinI = 1 // INTEGER rowMaxI = 0 // INTEGER columnI = 0 // INTEGER columnMinI = 1 // INTEGER columnMaxI = 0 // INTEGER columnBeginI = 0 // INTEGER columnEndI = 0 // INTEGER xTranslateMinI = 0 // INTEGER xTranslateI = xTranslateMinI // INTEGER xTranslateStepI = 15 // INTEGER bufferId = 0 // IF ( NOT IsCursorInBlock() ) // Warn( "Please mark a block first" ) // RETURN() // ENDIF // PushPosition() // PushPosition() // bufferId = CreateTempBuffer() // PopPosition() // PROCBlockGetDatabaseColumnWidthMaximumVariable( variableNameArraySA, variableNameMaximumSA, separatorS ) // rowMaxI = FNBlockGetDatabaseRowTotalCommaSeparatedValueI() // columnMaxI = FNBlockGetDatabaseLineColumnTotalLineCommaSeparatedValueI( variableNameArraySA, separatorS ) // GotoBlockBegin() // goto first line of block // // go through all the rows of the given data // FOR rowI = rowMinI TO rowMaxI // // Add an empty line in the temporary buffer // PushPosition() // GotoBufferId( bufferId ) // EndFile() // AddLine() // BegLine() // PopPosition() // // for each of the given columns // FOR columnI = columnMinI TO columnMaxI // // Earlier the column position of the starting separator (e.g. ",") for that column was stored in a 2-dimensional array. Get that value. // columnBeginI = FNArrayGetVariableDimension2I( variableNameArraySA, rowI, columnI - 1 ) // // Earlier the column position of the ending separator (e.g. ",") for that column was stored in a 2-dimensional array. Get that value. // columnEndI = FNArrayGetVariableDimension2I( variableNameArraySA, rowI, columnI ) // // get the text between that column // GotoColumn( columnBeginI + 1 ) // remove the front separator // // Remove spaces in front // WHILE CurrChar() == ASC( " " ) // Right() // ENDWHILE // MarkStream() // GotoColumn( columnEndI - 1 ) // remove the end separator // MarkStream() // // copy that text // Copy() // // paste that text in the buffer // PushPosition() // GotoBufferId( bufferId ) // GotoColumn( xTranslateI ) // Paste( _OVERWRITE_ ) // // goto the next column position in the buffer (linear transformation: translation + scaling) // xTranslateI = xTranslateI + FNArrayGetVariableDimension1I( variableNameMaximumSA, columnI ) + xTranslateStepI // PopPosition() // ENDFOR // // go back to the initial x-position in the buffer, to start the next line // xTranslateI = xTranslateMinI // Down() // ENDFOR // PopPosition() // GotoBufferId( bufferId ) // END // library: string: get: column: separator: array <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=getstsar.s) [<Program>] [<Research>] [kn, ho, tu, 05-02-2008 15:55:19] STRING PROC FNStringGetColumnSeparatorArrayS() // e.g. PROC Main() // e.g. Message( FNStringGetColumnSeparatorArrayS() ) // gives e.g. "columnSeparatorPositionS" // e.g. END // e.g. // e.g. <F12> Main() // RETURN( "columnSeparatorPositionSA" ) // END // library: string: get: column: separator: array: maximum <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=getstama.s) [<Program>] [<Research>] [kn, ri, fr, 08-02-2008 00:51:07] STRING PROC FNStringGetColumnSeparatorArrayMaximumS() // e.g. PROC Main() // e.g. Message( FNStringGetColumnSeparatorArrayMaximumS() ) // gives e.g. ..."" // e.g. END // e.g. // e.g. <F12> Main() // RETURN( "columnWidthMaximumSA" ) // END // library: block: get: database: column: width: maximum: variable <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getblmva.s) [<Program>] [<Research>] [kn, ri, th, 07-02-2008 22:23:20] PROC PROCBlockGetDatabaseColumnWidthMaximumVariable( STRING variableNameArraySA, STRING variableNameMaximumSA, STRING separatorS ) // e.g. PROC Main() // e.g. PROCBlockGetDatabaseColumnWidthMaximumVariable( FNStringGetColumnSeparatorArrayS(), FNStringGetColumnSeparatorArrayMaximumS(), "," ) // e.g. END // e.g. // e.g. <F12> Main() // // example // /* // 5, 4, 6, 4, 4, 3 // 5, 4, 4, 4, 4, 8 // 4, 4, 3, 6, 5, 5 // 1234567890123456789012345678901234567890 // 6 11 18 23 28 // aaaa, bbb, ccccc, ddd, eee, ff // dddd, eee, fff, ggg, hhh, iiiiiii // jjsasdsfasdfasdfj, kkk, ll, mmmmm, nnnn, oooo // */ // INTEGER rowI = 0 // INTEGER rowMinI = 1 // INTEGER rowMaxI = 0 // INTEGER columnI = 0 // INTEGER columnMinI = 1 // INTEGER columnMaxI = 0 // INTEGER columnBeginI = 0 // INTEGER columnEndI = 0 // INTEGER columnLengthI = 0 // INTEGER columnLengthMaxI = 0 // PushPosition() // IF ( NOT IsCursorInBlock() ) // Warn( "Please mark a block first" ) // PopPosition() // RETURN() // ENDIF // rowMaxI = FNBlockGetDatabaseRowTotalCommaSeparatedValueI() // columnMaxI = FNBlockGetDatabaseLineColumnTotalLineCommaSeparatedValueI( variableNameArraySA, separatorS ) // // +-begin of line +-End of line // // | | // // | column(1) column(2) column(3) column(4) column(5) column(6) | // // v+-------------+ +-------------+ +-------------+ +-------------+ +-------------+ +-------------+v // // 0+-------------+,+-------------+, +-------------+, +-------------+,+-------------+,+-------------+ // // ^ ^ ^ ^ ^ ^ ^ // // | | | | | | | // // +-separator(0) +-separator(1) +-separator(2) +-separator(3) +-separator(4) +-separator(5) +-separator(6) // // columnlength(1) = separator(1) - separator(0) - 1 // // columnlength(2) = separator(2) - separator(1) - 1 // // columnlength(3) = separator(3) - separator(2) - 1 // // columnlength(4) = separator(4) - separator(3) - 1 // // columnlength(5) = separator(5) - separator(4) - 1 // // columnlength(6) = separator(6) - separator(5) - 1 // // ... // // columnlength( I ) = separator( I ) - separator( I - 1 ) - 1 // // reset all the maximum counters for all columns to zero // PROCArraySetVariableResetAllDimension1( variableNameMaximumSA, columnMinI - 1, columnMaxI ) // GotoBlockBegin() // goto first line of block // FOR rowI = rowMinI TO rowMaxI // // calculate total amount of columns in the given data, and store the separator positions in a 1-dimensional array // columnMaxI = FNLineGetDatabaseColumnTotalLineCommaSeparatedValueI( variableNameArraySA, separatorS ) // // Because you read the data here 2 times, // // the first time reading the data you can store information already in an an array. // // You then have to calculate the separator position only once, // // if you need it the second time, you just read that values from that array, and do not have to calculate it again so) // // Store separator column distances for that row, in 2-dimensional array // // (because each row has different column separator positions) // FOR columnI = columnMinI TO ( columnMaxI - 1 ) // // Initialize the separator positions for that row, by copying from the 1-dimensional column separator array // PROCArraySetVariableDimension2( variableNameArraySA, rowI, columnI, Str( FNArrayGetVariableDimension1I( variableNameArraySA, columnI ) ) ) // ENDFOR // // store the first separator position (0) as being at character position 0 in that line // PROCArraySetVariableDimension2( variableNameArraySA, rowI, columnMinI - 1, "0" ) // begin of line // // store the last separator position, as position end of line // PushPosition() // end of line // EndLine() // columnEndI = CurrCol() // PopPosition() // PROCArraySetVariableDimension2( variableNameArraySA, rowI, columnMaxI, Str( columnEndI ) ) // end of line // // Now go through all the columns of that line, and determine the maximum longest line for each of the columns // FOR columnI = columnMinI TO columnMaxI // columnBeginI = FNArrayGetVariableDimension2I( variableNameArraySA, rowI, columnI - 1 ) // columnEndI = FNArrayGetVariableDimension2I( variableNameArraySA, rowI, columnI ) // columnLengthI = columnEndI - columnBeginI - 1 // columnLengthMaxI = FNArrayGetVariableDimension1I( variableNameMaximumSA, columnI ) // IF ( columnLengthMaxI < columnLengthI ) // PROCArraySetVariableDimension1( variableNameMaximumSA, columnI, Str( columnLengthI ) ) // ENDIF // ENDFOR // Down() // goto next line // ENDFOR // // PROCArrayViewVariableDimension2( variableNameArraySA, rowMinI, columnMinI, rowMaxI, columnMaxI ) // PopPosition() // END // library: text: get: database: column: total: line: comma: separated: value <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=gettesva.s) [<Program>] [<Research>] [kn, ho, tu, 05-02-2008 14:12:07] INTEGER PROC FNBlockGetDatabaseRowTotalCommaSeparatedValueI() // e.g. PROC Main() // e.g. Message( FNBlockGetDatabaseRowTotalCommaSeparatedValueI() ) // gives e.g. ..."" // e.g. END // e.g. // e.g. <F12> Main() // INTEGER rowBeginI = Query( blockBegLine ) // INTEGER rowEndI = Query( blockEndLine ) // RETURN( rowEndI - rowBeginI + 1 ) // END // library: block: get: database: line: column: total: line: comma: separated: value <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getblsvf.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 02:19:53] INTEGER PROC FNBlockGetDatabaseLineColumnTotalLineCommaSeparatedValueI( STRING variableNameS, STRING separatorS ) // e.g. PROC Main() // e.g. Message( FNBlockGetDatabaseLineColumnTotalLineCommaSeparatedValueI( FNStringGetColumnSeparatorArrayS(), "," ) ) // e.g. END // e.g. // e.g. <F12> Main() // INTEGER columnMaxI = 0 // IF ( NOT IsCursorInBlock() ) // Warn( "Please mark a block first" ) // PopPosition() // RETURN( 0 ) // ENDIF // PushPosition() // GotoBlockBegin() // columnMaxI = FNLineGetDatabaseColumnTotalLineCommaSeparatedValueI( variableNameS, separatorS ) // PopPosition() // RETURN( columnMaxI ) // END // library: array: get: variable: dimension2 <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getarvdi.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 01:24:30] INTEGER PROC FNArrayGetVariableDimension2I( STRING variableNameS, INTEGER rowI, INTEGER columnI ) // e.g. PROC Main() // e.g. Message( FNArrayGetVariableDimension2I( FNStringGetColumnSeparatorArrayS(), 1, 1 ) ) // gives e.g. 1 // e.g. END // e.g. // e.g. <F12> Main() // RETURN( FNStringGetToIntegerI( FNArrayGetVariableDimension2S( variableNameS, rowI, columnI ) ) ) // END // library: array: get: variable: dimension1 <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getblsve.s) [<Program>] [<Research>] [kn, ho, mo, 04-02-2008 17:37:41] INTEGER PROC FNArrayGetVariableDimension1I( STRING variableNameS, INTEGER rowI ) // e.g. PROC Main() // e.g. Message( FNArrayGetVariableDimension1I( FNStringGetColumnSeparatorArrayS(), 1 ) ) // gives e.g. 1 // e.g. END // e.g. // e.g. <F12> Main() // RETURN( FNStringGetToIntegerI( FNArrayGetVariableDimension1s( variableNameS, rowI ) ) ) // END // library: array: set: variable: reset: all <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=setarral.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 01:09:05] PROC PROCArraySetVariableResetAllDimension1( STRING variableNameS, INTEGER minI, INTEGER maxI ) // e.g. PROC Main() // e.g. PROCArraySetVariableResetAllDimension1( FNStringGetColumnSeparatorArrayS(), 1, 3 ) // e.g. END // e.g. // e.g. <F12> Main() // INTEGER I = 0 // FOR I = minI TO maxI // PROCArraySetVariableDimension1( variableNameS, I, "" ) // ENDFOR // END // library: text: get: database: column: total: line: comma: separated: value <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=gettesva.s) [<Program>] [<Research>] [kn, ho, tu, 05-02-2008 14:12:07] INTEGER PROC FNLineGetDatabaseColumnTotalLineCommaSeparatedValueI( STRING variableNameS, STRING separatorS ) // e.g. PROC Main() // e.g. Message( FNLineGetDatabaseColumnTotalLineCommaSeparatedValueI( FNStringGetColumnSeparatorArrayS(), "," ) ) // gives e.g. 6 columns if five times the column separator is found on that line (e.g. aaa, bb, cccc, ddd, ee, f) // e.g. END // e.g. // e.g. <F12> Main() // RETURN( FNLineGetDatabaseSeparatorTotalCommaSeparatedValueI( variableNameS, separatorS ) + 1 ) // END // library: array: set: variable: dimension2 <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=setarvdi.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 01:23:57] PROC PROCArraySetVariableDimension2( STRING variableNameS, INTEGER rowI, INTEGER columnI, STRING s ) // e.g. PROC Main() // e.g. PROCArraySetVariableDimension2( "columnSeparatorPositionS", 1, 1, "1" ) // e.g. Message( FNArrayGetVariableDimension2S( FNStringGetColumnSeparatorArrayS(), 1, 1 ) ) // gives e.g. "1" // e.g. END // e.g. // e.g. <F12> Main() // SetGlobalStr( variableNameS + Str( rowI ) + "_" + Str( columnI ), s ) // END // library: array: set: variable <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=setarsva.s) [<Program>] [<Research>] [kn, ho, tu, 05-02-2008 15:48:53] PROC PROCArraySetVariableDimension1( STRING variableNameS, INTEGER rowI, STRING s ) // e.g. PROC Main() // e.g. PROCArraySetVariableDimension1( "columnSeparatorPositionS", 1, "1" ) // e.g. Message( FNArrayGetVariableDimension1S( FNStringGetColumnSeparatorArrayS(), 1 ) ) // gives e.g. 1 // e.g. END // e.g. // e.g. <F12> Main() // SetGlobalStr( variableNameS + Str( rowI ), s ) // END // library: string: get: to: integer convert a string to an integer <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getsttio.s) [<Program>] [<Research>] [string to number] [kn, ni, mo, 03-08-1998 00:32:54] INTEGER PROC FNStringGetToIntegerI( STRING s ) // e.g. PROC Main() // e.g. Message( FNStringGetToIntegerI( "3" ) ) // gives e.g. 3 // e.g. END // e.g. // e.g. <F12> Main() // RETURN( Val( s ) ) // END // library: array: get: variable: dimension2s <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getarvdi.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 01:24:30] STRING PROC FNArrayGetVariableDimension2S( STRING variableNameS, INTEGER rowI, INTEGER columnI ) // e.g. PROC Main() // e.g. Message( FNArrayGetVariableDimension2S( FNStringGetColumnSeparatorArrayS(), 1, 1 ) ) // gives e.g. "1" // e.g. END // e.g. // e.g. <F12> Main() // RETURN( GetGlobalStr( variableNameS + Str( rowI ) + "_" + Str( columnI ) ) ) // END // library: array: get: variable: dimension1s <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getarvdj.s) [<Program>] [<Research>] [kn, ri, sa, 09-02-2008 19:56:46] STRING PROC FNArrayGetVariableDimension1S( STRING variableNameS, INTEGER rowI ) // e.g. PROC Main() // e.g. Message( FNArrayGetVariableDimension1S( FNStringGetColumnSeparatorArrayS(), 1 ) ) // gives e.g. "1" // e.g. END // e.g. // e.g. <F12> Main() // RETURN( GetGlobalStr( variableNameS + Str( rowI ) ) ) // END // library: line: get: database: separator: total: comma: separated: value <description></description> <version control></version control> <version>1.0.0.0.0</version> (filenamemacro=getlisvcm.s) [<Program>] [<Research>] [kn, ho, tu, 05-02-2008 14:12:07] INTEGER PROC FNLineGetDatabaseSeparatorTotalCommaSeparatedValueI( STRING variableNameS, STRING separatorS ) // e.g. PROC Main() // e.g. Message( FNLineGetDatabaseSeparatorTotalCommaSeparatedValueI( FNStringGetColumnSeparatorArrayS(), "," ) ) // gives e.g. 5 separators if five times the column separator is found on that line (e.g. aaa, bb, cccc, ddd, ee, f) // e.g. END // e.g. // e.g. <F12> Main() // INTEGER I = 0 // I = FNBlockGetDatabaseLineTableColumnSeparatorMaxI( variableNameS, separatorS ) // RETURN( I ) // END // library: block: get: database: line: table: column: separator: max <description></description> <version control></version control> <version>1.0.0.0.1</version> (filenamemacro=getblsmb.s) [<Program>] [<Research>] [kn, ho, tu, 05-02-2008 15:06:56] INTEGER PROC FNBlockGetDatabaseLineTableColumnSeparatorMaxI( STRING variableNameS, STRING separatorS ) // e.g. PROC Main() // e.g. Warn( FNBlockGetDatabaseLineTableColumnSeparatorMaxI( FNStringGetColumnSeparatorArrayS(), "," ) ) // gives e.g. 5 (if 5 commas found in current line) // e.g. Warn( FNBlockGetDatabaseLineTableColumnSeparatorMaxI( FNStringGetColumnSeparatorArrayS(), "|" ) ) // gives e.g. 0 // e.g. END // e.g. // e.g. <F12> Main() // // | NR | MONEY: AMOUNT | DESCRIPTION | DATE | // INTEGER I = 1 - 1 // counter for column header separator position // INTEGER minI = 1 // INTEGER maxI = minI // INTEGER C // PushPosition() // IF ( NOT IsCursorInBlock() ) // Warn( "Please mark a block first" ) // PopPosition() // RETURN( 0 ) // ENDIF // WHILE LFind( separatorS, "c" ) // get the column separator // C = CurrCol() // get position of begin of that column header, at current position // Right() // I = I + 1 // increase a column header counter // PROCArraySetVariableDimension1( variableNameS, I, Str( C ) ) // ENDWHILE // maxI = I // PopPosition() // RETURN( maxI ) // END
--- cut here: end ---------------------------------------------------- 5. -Tested successfully on Microsoft Windows 7 Ultimate (64 bits) service pack 1 running TSE v4.40.90 === Book: see also: === Diagram: see also: === File: see also: === File: version: control: see also: === Help: see also: === Image: see also: === Internet: see also: --- Computer: Editor: Text: TSE: Comma: Separated: Value: Link: Can you give an overview of links? http://goo.gl/a2Y01 === Podcast: see also: === Record: see also: === Screencast: see also: === Table: see also: === Video: see also: === <version>1.0.0.0.1</version> ----------------------------------------------------------------------

Share |

This web page is created and maintained using the Semware TSE text editor