Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

javascript - 在用户界面上解析上传的CSV文件(约8GB)时,将非常大的JSON对象存储在内存中(Store very large JSON Object in memory while parsing uploaded CSV file (approx. 8GB) on the UI)

I have a functionality where the user can browse CSV file approx.(我有一个功能,用户可以浏览大约 CSV文件)

size 8GB on the UI.(UI上的大小为8GB 。) Once the UI has the File object I used Papa Parse to parse the CSV file, which works like a charm.(一旦UI具有File对象,我就可以使用Papa Parse解析CSV文件了,它就像一个超级按钮。) While parsing I am constructing an object from each CSV record by doing some manipulation on data.(解析时,我通过对数据进行一些操作从每个CSV记录构造一个对象 。) As the parsing proceeds, the size on the object keeps on increasing and ultimately parsing fails with browser displaying out of memory exception .(随着解析的进行, 对象的大小不断增加,最终解析失败,浏览器显示内存不足异常 。) The object size constructed will be pretty less around 2 GB after data manipulation of CSV but it fails even before this.(在CSV进行数据处理后,构造的对象大小将小得多,约为2 GB,但在此之前甚至失败。) Is there a way to handle such large objects on the UI?(有没有办法在UI上处理如此大的对象?)   ask by Saurabh Verma translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You may not be using the parser correctly(您可能没有正确使用解析器)

Did I mention the file is huge?(我是否提到文件很大?) See All configuration : https://www.papaparse.com/docs#config(请参阅所有配置: https : //www.papaparse.com/docs#config) Try with worker: true The most typical reason to use a web worker is if your web page becomes unresponsive during parsing.(尝试使用worker:true使用Web Worker的最典型原因是,如果您的网页在解析过程中没有响应。) In other words, if it freezes and you can't click things or the scrolling becomes choppy.(换句话说,如果冻结,您将无法单击内容,或者滚动变得断断续续。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...