Skip to content

Commit 4d77231

Browse files
committed
completi upto object conversion and circle ci
1 parent 1c8abb7 commit 4d77231

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const mess=require('./js/wdiUrban.js');
2+
mess(1);

js/wdiUrban.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
let convert;
2+
let radix;
23
convert = function(x)
34
{
4-
if(isNaN(x))
5+
// Checking is number or not
6+
if(isNaN(x))
57
{
68
throw new Error('Not a number');
79
}
@@ -18,10 +20,13 @@ let convert;
1820
let result1 = [];
1921
let encoding = 'utf8';
2022
const rl = readline.createInterface({
21-
input: fs.createReadStream('./inputdata/Indicators.csv')
23+
// Reading file form file system
24+
input: fs.createReadStream('./../inputdata/Indicators.csv')
2225
});
26+
// Fetching line by line
2327
rl.on('line', function(line) {
2428
let lines = line.trim().split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
29+
// Checking required reqirements
2530
if(lines.includes('India') && (lines.includes('Urban population (% of total)') ||
2631
lines.includes('Rural population (% of total population)')))
2732
{
@@ -39,20 +44,16 @@ let convert;
3944
}
4045
});
4146
rl.on('close', function() {
42-
let m = 0;
43-
let n = 0;
4447
for(let i1 = 1960; i1 <= 2014; i1 = i1 + 1)
4548
{
46-
m=0,n=0;
49+
let m = 0; let n = 0;
4750
output.map(function(x1)
4851
{
49-
if(parseInt(x1.Year) === i1)
52+
if(parseInt(x1.Year, radix) === i1)
5053
{
51-
console.log("hell")
5254
if(x1.IndicatorName === 'Urban population (% of total)')
5355
{
5456
m = parseFloat(x1.Value);
55-
console.log("hello")
5657
}
5758
if(x1.IndicatorName === 'Rural population (% of total population)')
5859
{
@@ -65,7 +66,9 @@ let convert;
6566
result1.push(result);
6667
result = {};
6768
}
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);
6972
});
7073

7174
return 'JSON written successfully';

0 commit comments

Comments
 (0)