eboughey1008
Programmer
I created several different templates for my data files when I import from csv to my dbf and the program should know which template to use for importing by my naming conventions. For instance, one csv file has Name, address, address2, city, state, zip (Car dealer PC list stru1.csv). The second template doesn't have an address2 field (Car dealer PC list stru2.csv) and yet another template has first and last name instead of name field (Car dealer PC list stru3.csv).
I have a do while to import below but it isn't working (it keeps using the wrong templates), plus I have to rewrite the same code for each do while statement. I'd like to set up an 'if' statement so that the program looks at a filename and determines which .dbf file to use and import. Below is what I currently have:
lcFile = Sys(2000, lcPathAndMask)
thefile = "mailfile-import2.dbf"
use alltrim(lower(thefile))
ZAP
lcPathAndMask = alltrim(lcprefix)+"* PC*.csv"
Do While !Empty(lcFile) and 'stru2'$lcfile *** this uses mailfile2-import.dbf to import ***
APPEND FROM (lcFile) csv
replace listsource WITH (lcfile)for EMPTY(listsource)
lcFile = Sys(2000, lcPathAndMask, 1)
ENDDO
repl all list_no with left(CLIST_NO,5)
repl all tag with recno()
CLOSE ALL
clear
lcFile = Sys(2000, lcPathAndMask)
thefile = "mailfile-import.dbf"
use alltrim(lower(thefile))
ZAP
lcPathAndMask = alltrim(lcprefix)+"* PC*.csv"
Do While !Empty(lcFile) and !'stru2'$lcfile *** this uses mailfile-import.dbf to import ***
APPEND FROM (lcFile) csv
replace listsource WITH (lcfile)for EMPTY(listsource)
lcFile = Sys(2000, lcPathAndMask, 1)
ENDDO
repl all list_no with left(CLIST_NO,5)
repl all tag with recno()
CLOSE ALL
clear
I have a do while to import below but it isn't working (it keeps using the wrong templates), plus I have to rewrite the same code for each do while statement. I'd like to set up an 'if' statement so that the program looks at a filename and determines which .dbf file to use and import. Below is what I currently have:
lcFile = Sys(2000, lcPathAndMask)
thefile = "mailfile-import2.dbf"
use alltrim(lower(thefile))
ZAP
lcPathAndMask = alltrim(lcprefix)+"* PC*.csv"
Do While !Empty(lcFile) and 'stru2'$lcfile *** this uses mailfile2-import.dbf to import ***
APPEND FROM (lcFile) csv
replace listsource WITH (lcfile)for EMPTY(listsource)
lcFile = Sys(2000, lcPathAndMask, 1)
ENDDO
repl all list_no with left(CLIST_NO,5)
repl all tag with recno()
CLOSE ALL
clear
lcFile = Sys(2000, lcPathAndMask)
thefile = "mailfile-import.dbf"
use alltrim(lower(thefile))
ZAP
lcPathAndMask = alltrim(lcprefix)+"* PC*.csv"
Do While !Empty(lcFile) and !'stru2'$lcfile *** this uses mailfile-import.dbf to import ***
APPEND FROM (lcFile) csv
replace listsource WITH (lcfile)for EMPTY(listsource)
lcFile = Sys(2000, lcPathAndMask, 1)
ENDDO
repl all list_no with left(CLIST_NO,5)
repl all tag with recno()
CLOSE ALL
clear