I am using following code:
def saveUploadedInventory(self, inventory_file,user_id):
print "Inventory File"
with open('uploaded_inventory_sheet.csv','wb+') as destination:
for chunk in inventory_file.chunks():
destination.write(chunk)
print "Inventory Saved."
f = open('uploaded_inventory_sheet.csv','rb')
self.cur.copy_from(f, 'fk_payment_temp', sep=',', columns=('settlement_ref_no', 'order_type', 'fulfilment_type', 'seller_sku',
'wsn', 'order_id', 'order_item_id', 'order_date', 'dispatch_date', 'delivery_date',
'cancellation_date', 'settlement_date', 'order_status', 'quantity', 'order_item_value',
'sale_transaction_amount', 'discount_transaction_amount', 'refund',
'protection_fund', 'total_marketplace_fee', 'service_tax', 'swach_bharat_cess',
'settlement_value', 'commission_rate', 'commission', 'payment_rate',
'payment_fee', 'fee_discount', 'cancellation_fee', 'fixed_fee', 'emi_fee',
'total_weight', 'weight_type', 'shipping_fee', 'reverse_shipping_fee',
'shipping_zone', 'token_of_apology', 'pick_and_pack_fee', 'storage_fee',
'removal_fee', 'invoice_id', 'invoice_date', 'invoice_amount', 'sub_category',
'total_offer_amount', 'my_offer_share', 'flipkart_offer_share'))
It is giving following error:
invalid input syntax for type timestamp: "Order Date"
that mean clear there should be some date instead of Order Date
here order date is header.
In postgresql:
COPY Table_Name FROM 'wheat_crop_data.csv' DELIMITER ',' CSV HEADER;
how i can do this in python django ?
COPY FROMthe only way you accept, or creating the data via Django ORM is fine too?