deno.land / x / postal_code@v0.1.0 / read_raw.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { ensureFile, readCSVObjects } from "./deps.ts";import { PostalAddress } from "./types.ts";
const outputFilePath = "./.local/th/postal_codes.json";const f = await Deno.open("./raw-data/ThepExcel-Thailand-Tambon.csv");const addresses: Array<PostalAddress> = [];
for await (const row of readCSVObjects(f)) { addresses.push({ code: parseInt(row.PostCodeMajor), province: { en: row.ProvinceEng, th: row.ProvinceThai, }, district: { en: row.DistrictEngShort, th: row.DistrictThaiShort, }, subDistrict: { en: row.TambonEngShort, th: row.TambonThaiShort, }, region: row.Region, }); console.log("row:", addresses.at(-1));}
await ensureFile(outputFilePath);await Deno.writeTextFile(outputFilePath, JSON.stringify(addresses), { append: false,});
f.close();
postal_code

Version Info

Tagged at
a year ago