Python Forum
Insert 10gb csv files into sql table via python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert 10gb csv files into sql table via python
#3
(Apr-28-2023, 09:33 AM)mg24 Wrote: my csv file size is 10 gb,
For data this big is Dask or Polars better.
Dask DataFrame copies the pandas DataFrame API,so it will work the same as Pandas

Example with timing.
# pip install "dask[complete]"

import time
from dask import dataframe as dd

start = time.time()
df = dd.read_csv('large.csv')
end = time.time()
print(f"Total Time: {(end-start)} sec")
Just bye doing this so will Dask do a lot,eg a medium size .csv 230 mb,so dos Dask read it in 0.01-sec and Pandas read it in 6.2 sec.
Dask utilizes multiple CPU cores by internally chunking dataframe and process in parallel.
Example want to import 10 GB data in your eg 6 GB RAM or more RAM.
This can’t be achieved via Pandas since whole data in a single shot doesn’t fit into memory(without chunking up),but Dask can.
Dask instead of computing first, create a graph of tasks which says about how to perform that task.
It's lazy computation which means that Dask’s task scheduler creating a graph at first followed by computing that graph when requested.
Larz60+ likes this post
Reply


Messages In This Thread
RE: Insert 10gb csv files into sql table via python - by snippsat - Apr-28-2023, 04:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Serial: How to read the complete line to insert to MySQL? sylar 1 910 Mar-21-2023, 10:06 PM
Last Post: deanhystad
  python insert blank line in logger mg24 1 3,066 Nov-02-2022, 08:36 AM
Last Post: snippsat
  Add\insert header row existing csv files mg24 0 776 Oct-05-2022, 06:11 AM
Last Post: mg24
  store all variable values into list and insert to sql_summary table mg24 3 1,249 Sep-28-2022, 09:13 AM
Last Post: Larz60+
  Insert into SQL Table only when Table is First Created? Extra 4 1,576 Jun-28-2022, 07:50 AM
Last Post: Pedroski55
  Insert a multiple constant value after header in csv file using python shantanu97 1 1,213 Apr-24-2022, 10:04 AM
Last Post: Pedroski55
  Load the data from multiple source files to one table amy83 2 2,682 Apr-27-2021, 12:33 AM
Last Post: Pedroski55
  insert row and write to xlsx in python scttfnch 0 2,069 Feb-28-2021, 01:19 AM
Last Post: scttfnch
  Insert into mysql through python LaKhWaN 0 1,998 Aug-26-2020, 04:54 AM
Last Post: LaKhWaN
  How do I insert images in Python using gspread (or any other package)? ivansing23 0 2,346 Jul-27-2020, 01:26 PM
Last Post: ivansing23

Forum Jump:

User Panel Messages

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