Python Forum
Error when Inserting CSV file values into a postgreSQL using psycopg2
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error when Inserting CSV file values into a postgreSQL using psycopg2
#9
(Oct-05-2016, 02:38 PM)nilamo Wrote: 1.  That depends, what do you want to happen when they're blank?  Do you want to skip the row?  Have a blank value in the db?  Invent a random value?

2.  Use a date or datetime type for the column in the db, instead of char.  The db *might* be able to figure out how to format what you're giving it, but if it can't you'll have to parse it and format it in a way the db would understand (maybe dd/mm/yyyy, for example).

1. Yes i want to skip the blank values. eg- if one field in a variable is blank i can't make that variable to a bigint data type, How to overcome this? I think i can assign null, n/a or something similar to blank fields at the time of loading the CSV. How can i do that?

2. If the value in the field is similar to 20201220, can i make it to a date format 2020-12-20 in the db.
Thanks
Reply


Messages In This Thread
RE: Error when Inserting CSV file values into a postgreSQL using psycopg2 - by klllmmm - Oct-07-2016, 06:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 1,319 Jan-02-2024, 10:37 AM
Last Post: khanzain
  Trying to use 2 values from excel in my script but getting error.. cubangt 3 1,776 May-11-2022, 07:12 AM
Last Post: normanwolf
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,858 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Overwrite values in XML file with values from another XML file Paqqno 5 3,572 Apr-01-2022, 11:33 PM
Last Post: Larz60+
  How to split file by same values from column from imported CSV file? Paqqno 5 3,002 Mar-24-2022, 05:25 PM
Last Post: Paqqno
  How psycopg2 autocommit works ? johntay 3 10,994 Oct-08-2021, 11:22 AM
Last Post: Larz60+
  Psycopg2 doesn't work with python2 MedianykEugene 3 3,102 Aug-10-2021, 07:00 AM
Last Post: ndc85430
  Problems with inserting images into an Excel File FightingFarmer 2 3,523 May-12-2021, 10:03 PM
Last Post: FightingFarmer
  Printing x values from an csv file hobbyist 7 4,210 Mar-10-2021, 02:00 PM
Last Post: hobbyist
  Argparse error when inputting values tqader 2 3,002 Sep-11-2020, 07:42 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020