Hi, I have a .csv file that I'm trying to read from. Each line has approximately 400-600 characters (sometimes more). When I'm trying to use the fstream to read the line and put it into an object that I've created, it only takes the first 300 characters or so. I've checked the csv file and there isn't any '\n' (newline) escape characters that would make it stop there.
I did some research and it appears there might be a limit on getline but I wasn't able to find a solution that worked for me? Is that true and if so, how do I get it to input the entire line? The weird thing is, it reads the first 40 lines just fine and some of them are longer. Thank you for your help. Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
using namespace std;
#include <string>
#include <fstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
importZoho();
}
void importZoho()
{
ifstream fin ("zohotest.csv"); // Fstream operator
string input; // The string to put it in
int noOfZoho = 0; // Counter to keep track of how many objects I've created
vector<Zoho> zoho(15000); // A vector of objects I've created
while(getline(fin, input)) // While there is another line, put it into input
{
zoho[noOfZoho].setLine(input); // Sets the line in my object
zoho[noOfZoho].setPartNumber(getZohoPN(input)); // Sets the partnumber in the object using a non member function "getZohoPN" that I've created
zoho[noOfZoho].setPrice(getZohoPrice(input)); // Sets the price in the object using a non member function "getZohoprice" that I've created
++noOfZoho;
}
}
|
Here is a sample of just one line from my csv where it's getting stuck and only taking the first 300 characters or so:
zcrm_438903000000066507,zcrm_438903000000048003,Wiley Electronics WEEB 11.5 Grounding Clip,590-0038 WEEB-11.5,zcrm_438903000000066367,TRUE,Wiley Electronics,,,,,,zcrm_438903000000048003,zcrm_438903000000078304,40788.5375,40975.61458,,USD,1,1.99,0,Sales Tax,TRUE,Each,2900,-4400,0,,-4400,"Wiley Electronics, WEEB Grounding clip for DPW PowerTube CRS Rail Brackets,
WEEB-11.5",No,,WEEB-11.5,590-0038,1.99