locked
Problem with spaces in CSV file names RRS feed

  • Question

  • I have a line in my code where I use APPEND FROM &gcFile to import a CSV file and append it to a Foxpro table. 

    But I found the program doesn't work when the File name returned by the user has a space in the file name.

    It works fine when there is no space, but when i use APPEND FROM, IMPORT FROM, etc. it fails with "Command contains unrecognized keyword" when it gets to the APPEND FROM line in the code. It works just fine when the Folder Path to the CSV file does not have any spaces.

    Do you know of a modification I can make to the code where it will work, even when the folder name has a space in it?

    thanks

    bill

    Tuesday, October 15, 2019 10:41 PM

All replies

  • Hi Bill,

    when working with file- or directory names you should use named expressions instead of macro substitution. Not only for csv file but filenames per se, directories, tables, printers....

    SET ... TO ( cFilename )
    USE ( cTable ) ALIAS ( cAlias )
    CREATE TABLE/CURSOR ( cName )
    SELECT * FROM ( cSource ) INTO CURSOR/TABLE ( cTarget )
    SET PRINTER TO ( cPrintername )
    DIRECTORY( cCheckPathname )
    OPEN DATABASE ( cDBPathAndFilename )

    HTH


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011



    • Edited by Tom BorgmannEditor Wednesday, October 16, 2019 6:00 AM typos
    • Proposed as answer by LazyCod3r Thursday, October 31, 2019 3:09 PM
    Wednesday, October 16, 2019 5:59 AM
    Answerer