I am running a query using psycopg2 in python. The results of the query is saved to a list. I am trying to convert this list into a numpy array and then write to a csv file. Here is how I did that.
rows = rcursor.fetchall()
df = pd.DataFrame(np.array(rows), columns = rows("db1 db2 db3 db4 db5"))
df.to_csv('alldata.csv',sep=',')]
But when I do that i get the error :
ValueError: Must pass 2-d input
I guess I have to apply .reshape but the number of rows is huge (like 200000). The data fetched from query to list looks like this.
RealDictRow([('db1', '0001'), ('db2', 002), ('db3', 003), ('db4', '004'), ('db5', 'Hello I worked on this so far but not happening. Call my number 245-456-7892)
How can I write this to csv properly without getting the ValueError: Must pass 2-d input. Thanks in advance!