Fix several parsing issues.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import mkdirp from 'mkdirp'
|
||||
import path from 'path'
|
||||
import fs from 'fs/promises'
|
||||
import fs from 'fs'
|
||||
import fsp from 'fs/promises'
|
||||
import Papa from 'papaparse'
|
||||
|
||||
async function processSingleZip(zip) {
|
||||
async function processSingleZip({ date, zip }) {
|
||||
const output = {
|
||||
directory: `./public/data/testing-trend`,
|
||||
file: county => `${county}.json`
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.rm(output.directory, { recursive: true })
|
||||
await fsp.rm(output.directory, { recursive: true })
|
||||
} catch (e) {}
|
||||
|
||||
const csv = await zip.entryData('pcr_antigen.csv').then(res => res.toString())
|
||||
@@ -45,13 +46,14 @@ async function processSingleZip(zip) {
|
||||
}
|
||||
|
||||
await mkdirp(output.directory)
|
||||
await fs.writeFile(path.join(output.directory, output.file(county)), JSON.stringify(data))
|
||||
|
||||
await fsp.writeFile(path.join(output.directory, output.file(county)), JSON.stringify(data, null, '\t'))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function process (zips) {
|
||||
return Promise.all(zips.map(zip => processSingleZip(zip)))
|
||||
return processSingleZip(zips.at(-1))
|
||||
}
|
||||
|
||||
export default process
|
||||
|
||||
Reference in New Issue
Block a user