Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在React中逐行从磁盘读取大型csv文件?_Reactjs_Csv_Bigdata - Fatal编程技术网

Reactjs 如何在React中逐行从磁盘读取大型csv文件?

Reactjs 如何在React中逐行从磁盘读取大型csv文件?,reactjs,csv,bigdata,Reactjs,Csv,Bigdata,我有一个大数据类型的csv文件。我想逐行阅读,我不想内存溢出。我在找这个,但没找到。我看到的方法在React中不起作用,或者我不能起作用。例如 fs.createReadStream('path/to/my.csv')) .pipe(csv.parse({headers:true})) .on('data',row=>console.log(row)) 我发现了这个,我说,是的,这太棒了,但我从React得到了类似“createReadStream不是函数”的错误。请帮帮我,这对我很重要。 非常

我有一个大数据类型的csv文件。我想逐行阅读,我不想内存溢出。我在找这个,但没找到。我看到的方法在React中不起作用,或者我不能起作用。例如

fs.createReadStream('path/to/my.csv'))
.pipe(csv.parse({headers:true}))
.on('data',row=>console.log(row))

我发现了这个,我说,是的,这太棒了,但我从React得到了类似“createReadStream不是函数”的错误。请帮帮我,这对我很重要。
非常感谢

您好,createReadStream方法在React中不起作用。我使用get error。(类型错误:fs.createReadStream不是一个函数)我认为您不能在reactjs中使用fs模块,fs模块需要与nodejs一起执行,或者如果您只想显示数据,请使用我想要读取的这个包,并对数据进行一些处理。实际上我想要一个循环。每循环给我一行从csv。我想这并不难,但为什么我找不到也不明白。抱歉,我不明白。你能解释一下吗?
var fs = require('fs');   

     let readStream = fs.createReadStream('path/to/my.csv);
            let rows = [];

            // Handle any errors while reading
            readStream.on('error', err => {
                // handle error

            });

            // Listen for data
            readStream.on('data', chunk => {
                chunks.push(chunk);
            });

            // File is done being read
            readStream.on('close', () => {
                // Create a buffer of the image from the stream

            });