# Trouble With Huge CSVs

**URL:** <https://forum.kx.com/t/trouble-with-huge-csvs/12184>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [July 9, 2021, 2:59pm UTC](https://forum.kx.com/t/trouble-with-huge-csvs/12184 "2021-07-09T14:59:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![planefan](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@planefan](https://forum.kx.com/u/planefan)\
**Post date:** [July 9, 2021, 2:59pm UTC](https://forum.kx.com/t/trouble-with-huge-csvs/12184/1 "2021-07-09T14:59:00Z")

</div>

Greetings All,&nbsp;

I’ve got a couple 40gb CSVs that I’m hoping to perform some joins on.

I do not know the column format, or headers, or if headers are even in the csv.

Im working with a good bit of memory, with 256gb accessible.

Loading the files into memory clearly doesn’t work – as expected the program crashes.&nbsp;

So&nbsp; made my way here&nbsp;(loading from large files page). I understand I’ll have to convert my csvs to splayed tables, save those tables down and then work from there instead of using the csvs.&nbsp;

I’m able to see the rows inside the csv with&nbsp;.Q.fs[0N!]`:file.csv – I still don’t know the entirety of whats inside though.

I go through this little bit,&nbsp;

and obviously it’s too big and crashes the program. I try to insert the rows directly into a table on disk with&nbsp;.Q.fs[{`:newfile upsert flip colnames!("DFFFFIS";",")0:x}]`:file.csv and that crashes too

Should I be chunking this and going from that angle or is there a better way to do this?

&nbsp;

---

<div class="post-metadata">

**Author:** ![planefan](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@planefan](https://forum.kx.com/u/planefan)\
**Post date:** [July 9, 2021, 7:11pm UTC](https://forum.kx.com/t/trouble-with-huge-csvs/12184/2 "2021-07-09T19:11:00Z")

</div>

I’ve chunked with&nbsp;.Q.fs[{`trade insert flip colnames!(" **********";",")0:x}]`:filename and it runs until it crashed.&nbsp;

Did some more research and thought it could be a gc issue, so I added a gc call but that didn’t help me either.&nbsp;

Dumb question, is this bc I’m using w32 instead of w64?&nbsp;

---

<div class="post-metadata">

**Author:** ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)\
**Post date:** [July 11, 2021, 7:27am UTC](https://forum.kx.com/t/trouble-with-huge-csvs/12184/3 "2021-07-11T07:27:00Z")

</div>

Yes the w32 version has a limit to how much memory it can address, w64 does not have this restriction.

&nbsp;

You could also stream the data to an on disk table:

```
.Q.fs[{`:trade/ upsert flip colnames!(" **********";",")0:x}]`:filename  
trade:get `:trade/

```

- https://kx.com/blog/kx-product-insights-parsing-data-in-kdb/&nbsp;
- https://code.kx.com/q/kb/splayed-tables/

---

<div class="post-metadata">

**Author:** ![planefan](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@planefan](https://forum.kx.com/u/planefan)\
**Post date:** [July 18, 2021, 9:07pm UTC](https://forum.kx.com/t/trouble-with-huge-csvs/12184/4 "2021-07-18T21:07:00Z")

</div>

that was the move, thanks!&nbsp;
