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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with an Import from text

Status
Not open for further replies.

Very Noob

Technical User
Dec 25, 2022
3
0
0
RO
Hello, dear kind souls
I do not know foxpro at all and I do desperately need your help with something for work.
I do have a database already created by some ancient program written in Visual Foxpro 9.
I used the Import feature to import the text from *txt file in the TEXTA field, as you can see in the folowing image.
But i have to manually insert a string of numbers in the Personaj field, replacing those zeroes. I already to have the corespondence between the Texta text and the numbers that should go in the Personaj field, but I dont know how to put them there. The import feature doesnt work for replacing, I need the commands to do it in foxpro. Please help.
And to rephrase for simpicity,
I have a txt file with numbers, each row is a number, i need those numbers inserted in the database pictured here, in the Personaj field. Each row of the txt file should match the row in the database.
database_hzfvua.png

Thank you.
 
 https://files.engineering.com/getfile.aspx?folder=00a22e46-d6ba-4904-9c9b-288afb18c01d&file=image_2022-12-25_211641115.png
It would be more helpful to have a look at the txt file you need to import than to see an image of how far you got.

Import or Append are the commands to import txt files with comma separated values. The import wizard you find in the menu Tools-Wizards-Import might make it easier for you to get the import done.

PS: If you mean the import wizard by "the Import feature", then perhaps retry with other setting. It allows you to specify how to split up the input into fields by choosing the separator character.

Chriss
 
So I have this txt file with numbers

2
4
5
3
2
5
7
10
11
8
9

It is nothing special, if there are, lets say 249 rows of text inserted in the Texta field, I have the corresponding 249 rows of numbers for the Personaj field. I just need the inserted automatically, not manually.

And yes, I meant The Import Wizard, by "the Import feature", and I tried, it doesnt replace the 0s in the Personaj field, It just adds my row of numbers after them, where there is no corresponding Texta inputs.
 
Well, if you have separate files with numbers and texts, that's nothing you can import with the wizard or commands.
Not in one go, at least.

What's the reason you have separate files with data of one field each, that's a non-standard approach of data storage or data export. It should be fixed where that comes from already.

With what you have, you will never get somewhere in the long run. Don't make this your problem, you should get the data together in one file. It's so normal and standard, that's not asked much.

Chriss
 
I can put the data on the same file but I do not know how to import it then.
The only issue would be the separator, i cannot use , because that is used inside the text.
The thing is I dont know what commands to use to import it.
 
You must have overlooked that you can specify whatever other character can be the separator and that you specify it here in step 2a:

importwizardstep2a_anc8ot.png

You cannot only pick one of the given characters, with the "other" option you can enter whatever other separator character. |=pipe, for example, is not rarely used, as it's normally not part of data (texts).

By the way, csv is literally comma separated values but it stands for text data mainly, no matter what separator is used exactly, also bulk text import in MySQL, MSSQL Server etc. works on files with semicolon or pipe separated texts, instead. That's not a rare exception.

Besides that, there is the text delimiter (see right in the image, it's set to "Double Quotation Marks" - cut off at the Q). This means you can have a line [tt]2, "Hello, World"[/tt] which imports the tet including the comma. The same goes for the APPEND and IMPORT command, and that's CSV standard. The only thing VFP does not get right is, if the text between two quoation marks contains a newline.

Chriss
 
By the way, you have two commands for importing data, which are quite similar: APPEND and IMPORT. You can find them in the language reference in the section "commands":

helptoc_ru534o.png


(I'm not saying you could have found it, but now I told you those commands exist, or if you look into code you have, you always find the foxpro language in all the aspects described in help topic, for each command, for each function, for each class and all their properties and methods/events, etc.)

Chriss
 
I write a lot of routines for importing data from a variety of formats. You might want to start with something like this:

LOCAL lcFileName
CREATE CURSOR curImport (im_line N(5,0),im_fld2 C(10),im_fld2 C(10),im_fld3 C(40))
lcFileName=GETFILE()
IF !EMPTY(lcFileName)
SELECT curImport
APPEND FROM (lcFileName) TYPE DELIMITED WITH TAB
BROWSE NORMAL​
ENDIF

You'll need to change the CREATE CURSOR command to match your import file. Look up the help entry for APPEND FROM to see how to specify different ways of specifying the separator.
 
Right, APPEND FROM is the topic to read. Sorry for messing this up.



Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top