Skip to content

Instantly share code, notes, and snippets.

View raghavddps2's full-sized avatar
🎯
Focusing

Raghav Maheshwari raghavddps2

🎯
Focusing
View GitHub Profile
#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;
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);
}
const fs = require('fs');
const path = require('path');
var filePath = path.join(__dirname,'customer-data.csv');
var outPath = path.join(__dirname,'customer-data.json');
//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.
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.');
})
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);
@raghavddps2
raghavddps2 / ques.py
Last active July 29, 2019 13:00
This code works properly in jupyter notebook with the output decribed by the commented block in the below code. But when in Codezen it shows the key error.
## 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']
'''
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:
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;
}