Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy data from a deliminated file (using | instead of ,) to a cursor 2

Status
Not open for further replies.

PatMcLaughlin

Programmer
Dec 10, 2010
97
US
Every night we are downloading a .csv file from an FTP site. I then need to copy the data into a cursor. Here is what I did...
Code:
CREATE CURSOR WITCURSOR (WIT_NO C(8), ACTIVE C(1), SETUPCUDTE C(19), EXPIREDTE C(19), ;
	LAST1 C(30), FIRST1 C(30), N1_MIDDLE C(1), LAST2 C(30), FIRST2 C(30), N2_MIDDLE C(1), ;
	ATTN C(30), ADDR1 C(30), ADDR2 C(30), CITY C(20), STATE C(2), ZIP C(10), PHONE C(10), SNOW_ATTN C(30), ;
	SNOW_ADDR1 C(30), SNOW_ADDR2 C(30), SNOW_CITY C(30), SNOW_STATE C(2), SNOW_ZIP C(10), PHONE2 C(10), ;
	SERIAL C(8))

SELECT WITCURSOR
APPEND FROM (tcLoadFile) DELIMITED WITH _ WITH CHARACTER |

I cannot get any data to the cursor.
I have verified all fieldnames, their order, etc yet an empty cursor results. Any help for a dummy (Me)?
 
Nasib,

Can you clarify what your suggestion should achieve?

As far as I can see, the [tt]COPY TO t_2.txt SDF[/tt] and [tt]APPEND FROM t_2.txt SDF[/tt] will duplicate whatever records you entered manually in Append mode. The [tt]APPEND FROM x.x DELIMITED ...[/tt] should then append the records in the original text file, but only the first two fields.

Is that what you intended? And, if so, how does it take us forward?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike, you are right, this is exactly what I intended and is for debugging purposes only.

As we know, APPEND is not working for him. I thought of testing the basic stuff if that works. Many respondents have tested the code and it works. There is nothing wrong with the code. By experimenting the suggestion, he may discover a problem. We do not have his complete section of the code. May be the CSV file is empty and is pointing to a different location on the drive. May be there is no CR/LF and he only see the title row and saying it is empty.

I would add one more line before the last append statement.

modify file x.x nomodify && View if it is the same file and esc out

My best

naaib
 
Hi Pat,

Please read thoroughly the helpfile on the "APPEND" topic, especially the part concerning the CSV file

[link ][/url]

Furthermore please be aware that the CSV file does NOT ALWAYS have a comma as separator. You'll have to code accordingly.
e.g.
Code:
APPEND FROM lcfILE DELIMITED WITH CHARACTER ";"
hth
MK
 
Hi everyone...
I believe it was as I said, "A Friday Thing". I came in this morning, tried it again without changing anything just to refresh my memory of what was happening, and it worked without error. I have spent the last two hours trying to make it fail and it will not. I ended up with Olaf's code...
APPEND FROM (tcLoadFile) DELIMITED WITH CHARACTER |
Everything is happy and working as expected. I truely appreciate everyone's help! I wish I could tell you what fixed it in the end but obviously Mike and Olaf had it solved right away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top