1
1
let convert ;
2
+ let radix ;
2
3
convert = function ( x )
3
4
{
4
- if ( isNaN ( x ) )
5
+ // Checking is number or not
6
+ if ( isNaN ( x ) )
5
7
{
6
8
throw new Error ( 'Not a number' ) ;
7
9
}
@@ -18,10 +20,13 @@ let convert;
18
20
let result1 = [ ] ;
19
21
let encoding = 'utf8' ;
20
22
const rl = readline . createInterface ( {
21
- input : fs . createReadStream ( './inputdata/Indicators.csv' )
23
+ // Reading file form file system
24
+ input : fs . createReadStream ( './../inputdata/Indicators.csv' )
22
25
} ) ;
26
+ // Fetching line by line
23
27
rl . on ( 'line' , function ( line ) {
24
28
let lines = line . trim ( ) . split ( / , (? = (?: (?: [ ^ " ] * " ) { 2 } ) * [ ^ " ] * $ ) / ) ;
29
+ // Checking required reqirements
25
30
if ( lines . includes ( 'India' ) && ( lines . includes ( 'Urban population (% of total)' ) ||
26
31
lines . includes ( 'Rural population (% of total population)' ) ) )
27
32
{
@@ -39,20 +44,16 @@ let convert;
39
44
}
40
45
} ) ;
41
46
rl . on ( 'close' , function ( ) {
42
- let m = 0 ;
43
- let n = 0 ;
44
47
for ( let i1 = 1960 ; i1 <= 2014 ; i1 = i1 + 1 )
45
48
{
46
- m = 0 , n = 0 ;
49
+ let m = 0 ; let n = 0 ;
47
50
output . map ( function ( x1 )
48
51
{
49
- if ( parseInt ( x1 . Year ) === i1 )
52
+ if ( parseInt ( x1 . Year , radix ) === i1 )
50
53
{
51
- console . log ( "hell" )
52
54
if ( x1 . IndicatorName === 'Urban population (% of total)' )
53
55
{
54
56
m = parseFloat ( x1 . Value ) ;
55
- console . log ( "hello" )
56
57
}
57
58
if ( x1 . IndicatorName === 'Rural population (% of total population)' )
58
59
{
@@ -65,7 +66,9 @@ let convert;
65
66
result1 . push ( result ) ;
66
67
result = { } ;
67
68
}
68
- fs . writeFileSync ( './outputdata/worldDevIndicatorUrbanizationRaju.json' , JSON . stringify ( result1 ) , encoding ) ;
69
+ // Storing data in local file
70
+ fs . writeFileSync ( './outputdata/worldDevIndicatorUrbanizationRaju.json' ,
71
+ JSON . stringify ( result1 ) , encoding ) ;
69
72
} ) ;
70
73
71
74
return 'JSON written successfully' ;
0 commit comments