Skip to content

Instantly share code, notes, and snippets.

@Funi1234
Created February 21, 2016 01:41
Show Gist options
  • Save Funi1234/505d46800be01cec05c4 to your computer and use it in GitHub Desktop.
Save Funi1234/505d46800be01cec05c4 to your computer and use it in GitHub Desktop.
Convert Decked Builder CSV to Tapped Out Inventory Format
/**
* Created by Funi1234 on 21/02/2016.
*/
var csv = require('fast-csv'),
fs = require("fs"),
path = require("path");
var sets = {'Zendikar' :'(ZEN)',
'Journey into Nyx' :'(JOU)',
'Khans of Tarkir' :'(KTK)',
'Fate Reforged' :'(FRF)',
'Dragons of Tarkir' :'(DTK)',
'Magic Origins' :'(ORI)',
'Battle for Zendikar' :'(BFZ)',
'Commander 2015' :'(C15)',
'Oath of the Gatewatch' :'(OGW)'};
//Change Filename
var stream = fs.createReadStream("./MTG_Deck.csv")
.pipe(csv.parse({headers: true}))
.transform(function (row) {
return row["Total Qty"]+"x "+row["Card"]+" "+sets[row["Set"]];
/*{
id: row.id,
firstName: row["first_name"],
lastName: row["last_name"],
address: row.address
};*/
})
.on("readable", function () {
var row;
while (null !== (row = stream.read())) {
console.log(row);
}
})
.on("end", process.exit);
@yeago
Copy link

yeago commented Apr 24, 2017

tappedout now accepts csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment