@@ -16,7 +16,7 @@ const metaPath = join(__dirname, '..', 'tmp', 'TICON-4', 'meta.csv')
1616const dataPath = join ( __dirname , '..' , 'tmp' , 'TICON-4' , 'data.csv' )
1717const metadata = indexBy (
1818 parseCSV < TiconMetaRow > ( await readFile ( metaPath , 'utf-8' ) ) ,
19- 'FILE NAME'
19+ 'FILE NAME' ,
2020)
2121const data = await readFile ( dataPath , 'utf-8' )
2222
@@ -33,16 +33,14 @@ type TiconMetaRow = {
3333 * one JSON file with all its harmonic constituents aggregated.
3434 */
3535async function main ( ) {
36- const stations = Object . values ( groupBy ( parseCSV < TiconRow > ( data ) , ( r ) => r . tide_gauge_name ) )
36+ const stations = Object . values (
37+ groupBy ( parseCSV < TiconRow > ( data ) , ( r ) => r . tide_gauge_name ) ,
38+ )
3739
3840 let created = 0
3941
4042 for ( const rows of stations ) {
41- await save (
42- normalize (
43- convertStation ( rows )
44- )
45- )
43+ await save ( normalize ( convertStation ( rows ) ) )
4644 created ++
4745 process . stdout . write ( '.' )
4846 }
@@ -72,8 +70,8 @@ interface TiconRow {
7270}
7371
7472function dayMonthYearToDate ( date : string ) {
75- const [ day , month , year ] = date . split ( '/' ) . map ( ( v ) => parseInt ( v , 10 ) )
76- if ( ! day || ! month || ! year ) {
73+ const [ day , month , year ] = date . split ( '/' ) . map ( ( v ) => parseInt ( v , 10 ) )
74+ if ( ! day || ! month || ! year ) {
7775 throw new Error ( `Invalid date: ${ date } ` )
7876 }
7977 return new Date ( Date . UTC ( year , month - 1 , day , 0 , 0 , 0 ) )
@@ -83,7 +81,7 @@ function dayMonthYearToDate(date: string) {
8381 * Convert a TICON-4 station to our JSON schema format
8482 */
8583function convertStation ( rows : TiconRow [ ] ) : Station {
86- if ( ! rows [ 0 ] ) {
84+ if ( ! rows [ 0 ] ) {
8785 throw new Error ( 'No rows to convert' )
8886 }
8987
0 commit comments