• CSV, with Header,, easy way to rename headers,

    From Phil McGuinness@21:1/5 to All on Thu May 13 23:01:05 2021
    Quick, easy way to rename Headers of columns as they have spaces and mixed case and I want to import to PostGRES..

    Have to manually fix... easy first time but need to do it on same export from other clients data.

    Thanks in advance

    I was thinking maybe "Excel.application" load and some function that did this..

    Any ideas welcome

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Karl Faller@21:1/5 to Phil McGuinness on Fri May 14 23:15:38 2021
    Phil,
    something along....

    LOCAL cHeaderLine, cNewLine AS STRING
    ...
    cHeaderLine :=FReadLine(ptrHandle, cFilename)
    cNewLine := StrTran(cHeaderLine, " ", "")
    FWrite(Upper(cNewLine)
    FClose()

    ?

    But that might cause problems, as your line will shrink, so i'd rather
    replace the blanks with underscores...



    On Thu, 13 May 2021 23:01:05 -0700 (PDT), Phil McGuinness wrote:

    Quick, easy way to rename Headers of columns as they have spaces and mixed case and I want to import to PostGRES..

    Have to manually fix... easy first time but need to do it on same export from other clients data.

    Thanks in advance

    I was thinking maybe "Excel.application" load and some function that did this..

    Any ideas welcome
    Regards

    Karl

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Phil McGuinness@21:1/5 to All on Sat May 15 23:24:39 2021
    Karl

    cCSVContent := MemoRead(GetDefault() +"TheDataAs.csv")
    //
    aCSVdata := Conv2Array( cCSVContent, CRLF )
    aHeaders := Conv2Array( aCSVdata[1], [,] ) // The header
    //
    FOR xx := 1 TO ALen(aHeaders)
    aHeaders[xx] := AllTrim(Lower(aHeaders[xx]))
    aHeaders[xx] := StrTran(aHeaders[xx], _CHR(32))
    cNewCSVHeader += aHeaders[xx] + [,]
    NEXT
    //
    cNewCSVHeader := substr(cNewCSVHeader,1, slen(cNewCSVHeader)-1)
    //
    aCSVdata[1] := cNewCSVHeader+ CRLF
    //
    FOR xx := 1 TO ALen(aCSVdata)
    cCSVFixed += aCSVdata[xx]+CRLF
    NEXT
    //

    MemoWrit( GetDefault() +"TheDataFixed.csv", cCSVFixed )

    Phil
    --
    Phil,
    something along....

    LOCAL cHeaderLine, cNewLine AS STRING
    ...
    cHeaderLine :=FReadLine(ptrHandle, cFilename)
    cNewLine := StrTran(cHeaderLine, " ", "")
    FWrite(Upper(cNewLine)
    FClose()


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)