Write a C++ program that will input data from a Comma-separated values (.csv) file and output some information about it. This program uses a csv file from Yahoo Finance
(.csv) filename : SBUX.csv
1. Output the name of the ticker to the console screen (without the “.csv”)
2. Output the start date and end date that was found in the file
3. Output how many trading day(s) existed in the file
4. Prompt the use to input a number of records
5. Input the number of records from the console screen
6. Output the following heading to the console screen: Date Open A.Close Percent Change
8. Output the top x records for that ticker within the provided date range. Here x is the number of records that the user inputted previously. The top record is the record (row) that had the greatest percent change when comparing the open price to the adjusted close price (from the same day). The top records are the set of records that had the greatest percent changes amongst all records. The percent change is defined as follows: (adjusted close price – open price) / open price * 100 These records need to be displayed from highest percent change to lowest percent change. The program only needs to display the following information from that row: date, open price, adjusted close prices, and the percent change (for that 1 day).
9.The program will let the user know if they entered a number of records that is too large. It will continue to ask the user to input a number of records until they enter a number that is less than or equal to the number of trading day(s).
SBUX.csv sample information:
Date | Open | High | Low | Close | Adj Close | Volume |
1/1/2009 | null | null | null | null | null | null |
2/1/2009 | 4.63 | 5.385 | 4.45 | 4.575 | 3.668556 | 487465600 |
3/1/2009 | 4.49 | 6.215 | 4.06 | 5.555 | 4.454388 | 574769000 |
4/1/2009 | 5.495 | 7.72 | 5.405 | 7.23 | 5.797522 | 656683400 |
5/1/2009 | 7.21 | 7.25 | 6.26 | 7.195 | 5.769456 | 555559800 |
6/1/2009 | 7.285 | 7.7 | 6.77 | 6.945 | 5.568988 | 521311000 |
7/1/2009 | 6.99 | 8.95 | 6.38 | 8.85 | 7.096554 | 673380800 |
8/1/2009 | 8.99 | 9.925 | 8.835 | 9.495 | 7.61376 | 493708000 |
9/1/2009 | 9.49 | 10.47 | 9.105 | 10.325 | 8.279309 | 498955800 |
10/1/2009 | 10.27 | 10.555 | 9.345 | 9.49 | 7.609747 | 424346200 |
11/1/2009 | 9.49 | 11.05 | 9.425 | 10.95 | 8.780479 | 436812000 |
12/1/2009 | 10.975 | 11.975 | 10.475 | 11.53 | 9.245566 | 394275400 |
//Program in cpp
//program for getting first, last and trading days from existing file
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
using namespace std;
int main(){
ifstream infile("SBUX.csv");
ifstream countfile("SBUX.csv");
string line;
char *Lastday;
int
startfl=0,edflag=0,nulllinecount=0,linecount,paracount=7,count=0;
while (getline(countfile, line))//getting total record from
file
{
count++;
}
countfile.close();
while (getline(infile, line))
{
//cout<<line<<"\n";
int n = line.length();
// declaring character array
char char_array[n + 1];
//convert string to char array
strcpy(char_array, line.c_str());
linecount++;
if(strstr(char_array, "null") != NULL) {// if line consist null
then increase nullcount by 1
nulllinecount++;
continue;
}
//divide line it by , comma
char *token = strtok(char_array, ",");
int i=0;
while (token != NULL)//till end of file
{
if(i==0 &&
startfl==0){// condition for start trading day
printf("Start Trading
Day is %s\n", token);
startfl=1;
}
else if((count-1)==linecount
&& i==0){// condition for start trading day
printf("Last Trading Day is %s\n",
token);
}
i++;
token = strtok(NULL,
",");
}
}
printf(" Trading Days are %d ",linecount-nulllinecount+1);
infile.close();
}
/*
output
input file in SBUX.csv (open it in excel)
*/
//Program for accepting data from user and add it into input.csv file and getting first, last and trading days from accepted data
Program in c++
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <string>
#include <cstring>
#include <bits/stdc++.h>
using namespace std;
//program for getting first, last and trading days from existing
file
int main(){
ifstream infile("input.csv");
ofstream outfile("input.csv");
int nn,j;
cout<<" \n ENter the number of record for file";
cin>>nn;
string data;
int open,high,low,close, adjclose,volum;
//accept data from file
for(j=0;j<nn;j++){
cout<<"\n Enter Date,open,high,low,close,
adjclose,volum for record"<<j<<"\n";
cin>>data>>open>>high>>low>>close>>adjclose>>volum;
outfile<<data<<","<<open<<","<<high<<","<<low<<","<<close<<","<<adjclose<<","<<volum<<"\n";
}
outfile.close();
string line;
char *Lastday;
int
startfl=0,edflag=0,nulllinecount=0,linecount,paracount=7,count=0;
while (getline(infile, line))
{
//cout<<line<<"\n";
int n = line.length();
// declaring character array
char char_array[n + 1];
//convert string to char array
strcpy(char_array, line.c_str());
linecount++;
if(strstr(char_array, "null") != NULL) {// if line consist null
then increase nullcount by 1
nulllinecount++;
continue;
}
//divide line it by , comma
char *token = strtok(char_array, ",");
int i=0;
while (token != NULL)//till end of file
{
//cout<<"\n"<<(nn-1)<<"---"<<linecount<<"-"<<i;
if(i==0 &&
startfl==0){// condition for start trading day
printf("Start Trading
Day is %s\n", token);
startfl=1;
}
else if((nn-1)==linecount
&& i==0){// condition for start trading day
printf("Last Trading Day is %s\n",
token);
}
i++;
token = strtok(NULL,
",");
}
}
printf(" Trading Days are %d ",linecount-nulllinecount+1);
infile.close();
}
/*
output
input.csv
*/
Write a C++ program that will input data from a Comma-separated values (.csv) file and output som...
Write a C++ program that will input data from a Comma-separated values (.csv) file and output some information about it. This program uses a csv file from Yahoo Finance (.csv) filename : SBUX.csv 1. Output the name of the ticker to the console screen (without the “.csv”) 2. Output the start date and end date that was found in the file 3. Output how many trading day(s) existed in the file 4. Prompt the use to input a number of...
Pandas DataFrame in Python : I have csv file which has date column with object data type which ranges from 1908 to 2018: (Original) Date (My result) Date (I Need) Date 17-Sep-08 2008-09-17 1908-09-17 7-Sep-09 2009-09-07 1909-09-07 . (more years) . (more years) . . . . 8-Nov-07 2007-11-07 2007-11-07 23-Sep-08 2008-09-23 2008-09-23 29-Dec-18 2018-12-29 2018-12-29 When I am converting it to datetime64[ns] or/and adding column as year after extracting just year values from date...
C Programming, getting data from a file and computing them into 5 parallel arrays so that they can be used for later calculation. Also please avoid using structures at all costs for this code as they have not yet been covered. # Melbourne Central Daily Pedestrian Counts day 2 2009 2009 2009 06 06 06 01 02 03 daycount 22663 22960 23618 4 2018 2018 02 02 27 28 33722 33164 4 There will always be two heading lines in...
Create a program that will request for data entry for an experiment, so that one can enter information about the temperature of the measurements carried out. The output of the file, named records.csv should look like the following:no,date,time,temp1,1/11/21,9:00am,302,3/11/21,10:12am,313,4/11/21,9:30am,304,5/11/21,9:10am,28one should be able to stop the data entry by entering -1 for the column no.
C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...
Problem 1 (Reading Statistics) Write a function called read_stats(filename) that takes a csv (comma separated values) filename as an argument and returns a 2D list containing the statistics in that file. The returned list should contain lists of stats for each crime reported and should not include the header line from the file. The file crime_in_vancouver.csv (included in the folder) has the following structure: • The first row provides headers for each column • Each subsequent row represents the stats...
1. Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file. a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day. b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37...
I need to insert the data from a csv file which is look something like this . into the SQL table which that I've already created . How can i do it? listing_id date available price 0 241032 1 85 1 241032 1 85 2 241032 0 3 241032 0 4 241032 0 5 241032 0 241032 0 7 241032 0 8 241032 0 9 241032 1 85 10 241032 1 85 241032 11 0 12 241032 0 13 241032...
Java code BIRTHDAY GRAPH5 4B Input Standard input Output Standard output Topic Array & Array Processing Birthday Graph Problem Description Everyone loves to be celebrated on their birthdays. Birthday celebration can encourage positive social E interaction among co-workers, foster friendship among classmates or even strengthen bond between E BOBO Birthday graph can be display in many forms. It can a creative drawing consists of cupcakes, balloons, UU candles with names, or it can be in the form of simple bar...
Write in Java please. The purpose of this program is to read a file, called WaterData.csv. It will output date and gallons. So it would look something like "2/04/15 40 Gallons". The pseudo code is as follows. prompt the user for a file name open the file if that file cannot be opened display an error message and quit endif create a String variable 'currentDate' and initialize it to the empty string. create a variable gallonsUsed and initialize it to...