Tag: maxmind

从包含nodejs中的重音字符的文件读取

所以我parsing一个大的csv文件,并将结果推送到mongo。 该文件是maxminds城市数据库 。 它有各种有趣的utf8字符。 我仍然在一些城市名称中使用(?)符号。 这里是我如何阅读文件: (使用csv节点模块) csv().from.stream(fs.createReadStream(path.join(__dirname, 'datafiles', 'cities.csv'), { flags: 'r', encoding: 'utf8' })).on('record', function(row,index){ .. uninteresting code to add it to mongodb }); 我在这里做错了什么? 我在Mongo:Ch teauguay,加拿大得到这样的东西 编辑 : 我试着用不同的lib来读取文件: lazy(fs.createReadStream(path.join(__dirname, 'datafiles', 'cities.csv'), { flags: 'r', encoding: 'utf8', autoClose: true })) .lines .map(String) .skip(1) // skips the two lines that are iptables header […]