problem writing dataframe to oracle - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: problem writing dataframe to oracle (/thread-35044.html) |
problem writing dataframe to oracle - aliyesami - Sep-25-2021 i have a simple csv file as follows : and i have a table test(id, name ) the code is as follows minus DB connection details since connection is fine : #df=pd.read_csv('test.csv',encoding= 'unicode_escape', header = None) df=pd.read_csv('test.csv',encoding= 'unicode_escape' ) print(df) df.shape df.info() df.to_sql('test', engine, index=False, if_exists='append')[/python] I am trying to load the csv using pandas data frames but if i dont put the header in csv as "id,name" it does not insert rows and throws "invalid identifier " error. I want to load this csv file in the table without having to put a header . please advise .The code and error are below. Note: I have tried using header=None ,still doesnt work . Note2: plz note that if I put the header Id,Name in the csv file the code works fine and loads the rows in the table. see attached outputs for both cases , first one is without using the header clause and second case is using header clause. RE: problem writing dataframe to oracle - Larz60+ - Sep-25-2021 see: https://stackoverflow.com/a/47540978 RE: problem writing dataframe to oracle - aliyesami - Sep-25-2021 thanks but the link you posted has no relation to my issue. as I stated I don't have any issue in connection or loading as long as I keep the header . I want to know how to load the data when the csv file has no header RE: problem writing dataframe to oracle - aliyesami - Sep-25-2021 to any moderator: I think the thing i am trying to do is very common and simple , i am facing issue because I am novice. So I am surprised why I am not getting response . Did i post this in a wrong group ? please advise RE: problem writing dataframe to oracle - SamHobbs - Sep-25-2021 I am not sure I understand. If I understand then I do not know what your database field names are but perhaps you just need to use something as in the following. df=pd.read_csv('test.csv', names=["Id", "Name"]) |