# CSV data Write operation is very slow in speed using python

**URL:** <https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955>\
**Category:** Systems\
**Created:** [October 9, 2018, 10:15am UTC](https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955 "2018-10-09T10:15:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayesh\_joshi](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jayesh\_joshi](https://community.influxdata.com/u/jayesh_joshi)\
**Post date:** [October 9, 2018, 10:15am UTC](https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955/1 "2018-10-09T10:15:25Z")

</div>

When I write the csv file in influxdb, it takes quite long time to write the data. How to speed up process to write data using python ?

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [October 9, 2018, 7:50pm UTC](https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955/2 "2018-10-09T19:50:47Z")

</div>

Hello @jayesh_joshi,  
You might want to look into using the python client library and setting a large [batch\_size](https://influxdb-python.readthedocs.io/en/latest/api-documentation.html). I like this tutorial for [getting started with the python and influxdb](https://www.influxdata.com/blog/getting-started-python-influxdb/).  
**batch\_size** ( _int_ ) – value to write the points in batches instead of all at one time. Useful for when doing data dumps from one database to another or when doing a massive write operation, defaults to None

Is this helpful?

Best,

Anais

---

<div class="post-metadata">

**Author:** ![jayesh\_joshi](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jayesh\_joshi](https://community.influxdata.com/u/jayesh_joshi)\
**Post date:** [October 10, 2018, 5:08am UTC](https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955/3 "2018-10-10T05:08:54Z")

</div>

@Anaisdg … Thank you for your reply. I’ll try to implement that.

---

<div class="post-metadata">

**Author:** ![Puneet\_Gupta](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/puneet_gupta/32/3324_2.png) [@Puneet\_Gupta](https://community.influxdata.com/u/Puneet_Gupta)\
**Post date:** [July 17, 2019, 8:15am UTC](https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955/4 "2019-07-17T08:15:52Z")

</div>

Could you please check this doubt. I am not sure why it is not running for me.

> [@Measurement is not created in demo1 database when tried by pandas dataframe but able to create it so by json body in python](https://community.influxdata.com/t/measurement-is-not-created-in-demo1-database-when-tried-by-pandas-dataframe-but-able-to-create-it-so-by-json-body-in-python/10543):
>
> host = 'localhost' port = 8086 user = 'root' password = 'root' dbname = 'demo1' protocol = 'json' client = DataFrameClient(host, port, user, password, dbname) print("Create pandas DataFrame") df = pd.DataFrame(data=list(range(30)), index=pd.date\_range(start='2014-11-16', periods=30, freq='H'), columns=['0']) print("Create database: " + dbname) client.create\_database(dbname) print("Write DataFrame") client.write\_points(df, 'demo1', proto…

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [July 22, 2019, 4:01pm UTC](https://community.influxdata.com/t/csv-data-write-operation-is-very-slow-in-speed-using-python/6955/5 "2019-07-22T16:01:30Z")

</div>

Hello @Puneet_Gupta,  
Thank you for your question. You can’t write a df to the db. I believe you need to convert your df to line protocol. Can you please return some rows from your df?
