QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: George McGinn on July 22, 2021, 04:40:03 pm
-
Hello,
I am running into an issue were I am reading a record from a file, and part of the record there is a coma. I am not getting the entire record.
The file was created after a mySQL select returned a number of rows. I piped them to a file to test various ways to process them.
After the INPUT #1, qString$, the results are truncated from the comma on. It is not until I do another INPUT #1, qString$ that I get the rest of the record.
Here is one of the records, and the result from my program.
Record (TAB Delimited, but not the issue here as it still occurs when I change the TAB to a pipe):
7 Blondel père et fils Frédérique Citeaux 24, place Kléber Strasbourg 67000 France
This is what I am getting:
Length of qString$: 47
7 Blondel père et fils Frédérique Citeaux 24
After the next INPUT, I get (With the results):
Length of qString$: 37
place Kléber Strasbourg 67000 France
If I put the entire record in quotes, it works.
Is this a bug? Shouldn't I get the entire record, commas and all, as they are strings?
(And the answer is not to put the record in Quotes, as the results from mySQL does not do that as far as I know!)
-
Try LINE INPUT it doesnt stop on commas.
-
if a **value** includes commas, enclose the value in "quotation marks". INPUT for reading from a file reads it as a CSV - and that's one of the format's specifications.
-
@bplus - Thanks, that did it (I keep forgetting about LINE INPUT as I usually only use it for Binary files).
@FellippeHeitor - I will remember that. Unfortunately, dealing with data created by an external process does not always afford me the ability to put quotes around strings. Knowing that INPUT was designed to read CSV files is a help.
If I am reading in string data, LINE INPUT should be used. If I am reading/input to numeric variable(s) or comma-separated variables, then INPUT is the right statement.
Thanks.