# Trouble With Huge CSVs

**URL:** <https://forum.kx.com/t/trouble-with-huge-csvs/13484>\
**Category:** Community Support\
**Tags:** imported, kdb-and-q\
**Created:** [July 9, 2021, 12:00am UTC](https://forum.kx.com/t/trouble-with-huge-csvs/13484 "2021-07-09T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkerr2](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lkerr2/32/57_2.png) [@lkerr2](https://forum.kx.com/u/lkerr2)\
**Post date:** [July 9, 2021, 12:00am UTC](https://forum.kx.com/t/trouble-with-huge-csvs/13484/1 "2021-07-09T00:00:00Z")

</div>

[https://learninghub.kx.com/forums/topic/trouble-with-huge-csvs](https://learninghub.kx.com/forums/topic/trouble-with-huge-csvs)

Greetings All,

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.

So made my way [here](https://code.kx.com/q/kb/loading-from-large-files/") (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.

I’m able to see the rows inside the csv with .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 .Q.fs[{`:newfile</span> <span class="&quot;token">upsert</span> <span class="&quot;token">flip</span> colnames<span class="&quot;token">!</span><span class="&quot;token">(</span><span class="&quot;token">"DFFFFIS"</span><span class="&quot;token">;</span><span class="&quot;token">","</span><span class="&quot;token">)</span><span class="&quot;token">0:</span>x<span class="&quot;token">}</span><span class="&quot;token">]</span><span class="&quot;token">`: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:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [July 11, 2021, 12:00am UTC](https://forum.kx.com/t/trouble-with-huge-csvs/13484/2 "2021-07-11T00:00: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/](https://kx.com/blog/kx-product-insights-parsing-data-in-kdb/")
- [https://code.kx.com/q/kb/splayed-tables/](https://code.kx.com/q/kb/splayed-tables/")

---

<div class="post-metadata">

**Author:** ![lkerr2](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lkerr2/32/57_2.png) [@lkerr2](https://forum.kx.com/u/lkerr2)\
**Post date:** [July 9, 2021, 12:00am UTC](https://forum.kx.com/t/trouble-with-huge-csvs/13484/3 "2021-07-09T00:00:00Z")

</div>

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

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.

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