This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| #include<math.h> | |
| #include<stdlib.h> | |
| struct rect{ | |
| int xl,yl,xr,yr; | |
| }; | |
| int min(int a,int b){ | |
| int min = a; | |
| if(b<a){ | |
| return b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| var filePath = path.join(__dirname,'customer-data.csv'); | |
| var jsonArray = []; | |
| //This will read the file and list down the contents. | |
| fs.readFile(filePath,{encoding:'utf-8'},function(err,data){ | |
| if(err){ | |
| return console.log(err); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var filePath = path.join(__dirname,'customer-data.csv'); | |
| var outPath = path.join(__dirname,'customer-data.json'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //This is the array which will convert the json data. | |
| var jsonArray = []; | |
| //This will read the file. | |
| fs.readFile(filePath,{encoding:'utf-8'},function(err,data){ | |
| if(err){ | |
| return console.log(err); | |
| } | |
| //The following line will split the csv file line by line and store each of it in the vraiable dataArray. | |
| var dataArray = data.split("\n"); | |
| //This line helps us to obtain the keys for various values in the file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fs.writeFile(outPath,JSON.stringify(jsonArray,null,2),function(err){ | |
| if(err){ | |
| return console.log(err); | |
| } | |
| console.log('Hello! Voilla, you CSV file is converted to JSON file and stored in the same folder.'); | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| var filePath = path.join(__dirname,'customer-data.csv'); | |
| var outPath = path.join(__dirname,'customer-data.json'); | |
| var jsonArray = []; | |
| //This will read the file and list down the contents. | |
| fs.readFile(filePath,{encoding:'utf-8'},function(err,data){ | |
| if(err){ | |
| return console.log(err); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Open and read data file as specified in the question | |
| ## Print the required output in given format | |
| import csv | |
| with open('year2017.csv') as file_obj: | |
| file_data = csv.DictReader(file_obj) | |
| data_list = list(file_data) | |
| month_killed = {} | |
| for row in data_list: | |
| key = row['Month'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| Ques: Month Vs Klled | |
| ''' | |
| import csv | |
| file_obj = open('year2017.csv') | |
| file_data = csv.DictReader(file_obj) | |
| file_data = list(file_data) | |
| # print(file_data) | |
| monthDict = {} | |
| for row in file_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class PairSum{ | |
| public static boolean binarySearch(int arr[],int key,int low,int high){ | |
| while(low<=high){ | |
| int mid = (low+high)/2; | |
| if(arr[mid] == key){ | |
| return true; | |
| } |
OlderNewer