N
N
Nikolay Baranenko2017-08-22 09:11:40
Oracle
Nikolay Baranenko, 2017-08-22 09:11:40

How to save unloading from Oracle in CSV?

Hello.
I want to upload information from an Oracle object to a CSV file.
trying to do so

csv_file=open("C:\\DataBases\\csv\\%s_%s.csv" % (FILE_NAME, TABLE_NAME), "a")
# wr.writerow(mylist)
for row in cursor:
    result_inside={}
    for col, val in zip(col_names, row):
        result_inside[col] = val
    count_rows+=1
    result_select_from_oracle.append(result_inside)
    csv_file.csv.writer(result_inside, quoting=csv.QUOTE_ALL)
print("Обнаружено сторок: ",count_rows)
file.close();
csv_file.close();

BUT I get an error
csv_file.csv.writer(result_inside, quoting=csv.QUOTE_ALL)
AttributeError: '_io.TextIOWrapper' object has no attribute 'csv'

What am I doing wrong and how to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Baranenko, 2017-08-22
@drno-reg

the csv_file object doesn't really have a csv attribute :-)

writer= csv.writer(csv_file, delimiter=';')
    for line in data:
        writer.writerow(result_inside)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question