Oct-04-2023, 01:07 PM
(This post was last modified: Oct-04-2023, 01:07 PM by popular_dog.)
I'm trying to read from a cell in a csv file as a list, but I'm running into a problem.
csv_read prints out
how do I get the CSV to print out like text?
import csv from google.cloud import bigquery with open('documents\list.csv') as csvfile: reader = csv.DictReader(csvfile) for row in reader: csv_row=(row['Schema']) csv_read=csv_row.split('\n') text = [bigquery.SchemaField("Id","STRING", mode="NULLABLE")] print(csv_read) print(text)when I print both these statements, I'm getting two different results, even though the string in text and inside the CSV are exactly the same.
csv_read prints out
Output:['bigquery.SchemaField("Id","STRING", mode="NULLABLE")']
where text prints out Output:[SchemaField('Id', 'STRING', 'NULLABLE', None, None, (), None)]
I'm assuming the issue is that csv_read is reading as a complete string and not taking bigquery.schemafield as a module/class how do I get the CSV to print out like text?
Larz60+ write Oct-03-2023, 10:45 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Modified for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Modified for you this time. Please use BBCode tags on future posts.