# Import CSV file with django

**URL:** <https://forum.djangoproject.com/t/import-csv-file-with-django/1665>\
**Category:** Using Django\
**Created:** [March 26, 2020, 12:41am UTC](https://forum.djangoproject.com/t/import-csv-file-with-django/1665 "2020-03-26T00:41:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arielis](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/arielis/32/6647_2.png) [@Arielis](https://forum.djangoproject.com/u/Arielis)\
**Post date:** [March 26, 2020, 12:41am UTC](https://forum.djangoproject.com/t/import-csv-file-with-django/1665/1 "2020-03-26T00:41:01Z")

</div>

Hi,

I am trying to import a csv file in my database. For some reason, I don`t manage to loop the csv file and only the 1st line of the file is being displayed.

I`ve put every details on here [https://stackoverflow.com/questions/60806049/import-csv-file-with-django](https://stackoverflow.com/questions/60806049/import-csv-file-with-django)

Have you got an idea what is happening?

Thanks

---

<div class="post-metadata">

**Author:** ![claudep](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/claudep/32/5377_2.png) [@claudep](https://forum.djangoproject.com/u/claudep)\
**Post date:** [March 26, 2020, 7:13am UTC](https://forum.djangoproject.com/t/import-csv-file-with-django/1665/2 "2020-03-26T07:13:13Z")

</div>

There is a dedicated Python module for CSV handling: [https://docs.python.org/3/library/csv.html](https://docs.python.org/3/library/csv.html)  
Use that and do not try to parse the file yourself.

---

<div class="post-metadata">

**Author:** ![Arielis](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/arielis/32/6647_2.png) [@Arielis](https://forum.djangoproject.com/u/Arielis)\
**Post date:** [March 26, 2020, 3:09pm UTC](https://forum.djangoproject.com/t/import-csv-file-with-django/1665/3 "2020-03-26T15:09:12Z")

</div>

Thank you, I`ll change my code. By any chance, if you know any tutorial please let me know.

Thanks

---

<div class="post-metadata">

**Author:** ![claudep](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/claudep/32/5377_2.png) [@claudep](https://forum.djangoproject.com/u/claudep)\
**Post date:** [March 26, 2020, 6:09pm UTC](https://forum.djangoproject.com/t/import-csv-file-with-django/1665/4 "2020-03-26T18:09:12Z")

</div>

I’d say that the code samples in the official Python docs are already a good start.
