1

我从 csv 获取四舍五入的值作为字符串,我不希望值被四舍五入我需要来自 csv 的确切值有什么办法吗?

(async() => {
  try {
    let csvInUsers = []
    const jsonArray = await csv({
      trim: true
    }).fromFile(csvFilePath);

    //////     Invalid CSV   /////
    if (typeof jsonArray[0]['_id'] == 'undefined' ||
      typeof jsonArray[0]['playerId'] == 'undefined') {
      let error = new Error('Uploaded csv is invalid.');
      error.statusCode = 400;
      error.code = 'INVALID_CSV';
      fs.unlinkSync(csvFilePath);
      return cb(error);
    }
    //////     Invalid CSV   /////

    async.eachSeries(jsonArray, function(value, callback) {
      (async() => {
        try {
          UserCollection.updateOne({
            _id: ObjectId(value._id)
          }, {
            $set: {
              playerId: String(value.playerId)
            }
          })
          callback(null)
        } catch (error) {
          if (error) console.log(error);
          callback(error)
        }
      })();
    }, (err) => {
      if (err) console.log(err);
      fs.unlinkSync(csvFilePath);
      cb()
    });
  } catch (error) {
    cb(error)
  }
})();

7945160000000000 四舍五入到 7.95E+15 我期待读取 csv 中的确切值

4

0 回答 0