Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ please. I'm having trouble trying to input the contents of a txt. file into a 3 separate vectors to then be able to do

c++ please.

I'm having trouble trying to input the contents of a txt. file into a 3 separate vectors to then be able to do further calculations to the contents of the vectors. I just need help with the inputting of the contents of the txt file into vectors. I will leave an example of my text file below and my current code. Use whatever means necessary.

Example of my input file below:

image text in transcribed

1464815342.110273122787, 17.889999389648, 0.095994234085

1464815342.123246669769, 17.920000076294, 0.087267547846

1464815342.137223720551, 17.889999389648, 0.095994234085

1464815342.150209188461, 17.920000076294, 0.087267547846

1464815342.163207292557, 17.909999847412, 0.095994234085

1464815342.177282094955, 17.920000076294, 0.087267547846

1464815342.189191341400, 17.909999847412, 0.095994234085

1464815342.204182624817, 17.909999847412, 0.087267547846

1464815342.217026233673, 17.899999618530, 0.095994234085

1464815342.230037212372, 17.920000076294, 0.087267547846

1464815342.243027210236, 17.909999847412, 0.095994234085 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include #include #include #include #include #include using namespace std;

int main() {

string myString, line, FilterStatus; string timestamp, distance, angle;

vectortimestamp_v; vectordistance_v; vectorangle_v; vectorC_Y; const float pi = 3.1415;

ifstream inFile("inputFile1.txt"); if (!inFile.is_open()) { cout

} ofstream outFile; outFile.open("file1Output.txt");

//getline reads in the entire first line //storing in line while (!inFile.eof() && inFile.peek()) {

while (getline(inFile, line)) {

getline(inFile, timestamp, ','); timestamp_v.push_back(stof(timestamp)); getline(inFile, distance, ','); distance_v.push_back(stof(distance)); getline(inFile, angle, ' '); angle_v.push_back(stof(angle));

outFile

}//end while

} inFile.close(); outFile.close(); return 0; }

The input log consists of a timestamp, followed by distance and then angle information. TTTTT.TTT, DD.DD, A. AAA

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

8. Design office space to facilitate interaction between employees.

Answered: 1 week ago