Skip to content

Commit

Permalink
VS settings added
Browse files Browse the repository at this point in the history
- gitignore for Visual Studio added
- indentation set
  • Loading branch information
tmdghks0612 committed Jul 17, 2022
1 parent bdad606 commit 9887269
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 53 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

*.vsidx
*.lock
*.db
*.db-shm
*.db-wal
*.opendb
*.sqlite
*.suo
.vs/VSWorkspaceState.json
.vs/ProjectSettings.json
106 changes: 53 additions & 53 deletions source/generatecsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,80 @@ using namespace std;

bool jsonToCsv(shared_ptr<Json::Value> jsonInput, const char* input, const char* output)
{
Json::Reader jsonReader;
ifstream ifs(input);
Json::Reader jsonReader;
ifstream ifs(input);

// input file path validation check
if(ifs.is_open())
// input file path validation check
if (ifs.is_open())
{
istream& istream = ifs;
if (false == jsonReader.parse(istream, *jsonInput))
{
istream& istream = ifs;
if(false == jsonReader.parse(istream, *jsonInput))
{
cout << "[jsonToCsv Fail] jsonReader parse failed" << endl;
ifs.close();
return false;
}
}
else
{
cout << "[jsonToCsv Fail] no input file path : " << input << endl;
return false;
cout << "[jsonToCsv Fail] jsonReader parse failed" << endl;
ifs.close();
return false;
}
}
else
{
cout << "[jsonToCsv Fail] no input file path : " << input << endl;
return false;
}

// close file io streams
ifs.close();
return true;
// close file io streams
ifs.close();
return true;
}

objects_t jsonToDicts(shared_ptr<Json::Value> jsonInput)
{
objects_t objects = make_shared<json_column_plist>();
return objects;
objects_t objects = make_shared<json_column_plist>();
return objects;
}

shared_ptr<lines_t> dictsToCsv(objects_t o)
{
auto lines = make_shared<lines_t>();
return lines;
auto lines = make_shared<lines_t>();
return lines;
}

int main(int argc, char *argv[])
int main(int argc, char* argv[])
{
if(argc != 3)
{
cout << "2 arguments required. argument count : " << argc << endl;
exit(1);
}
if (argc != 3)
{
cout << "2 arguments required. argument count : " << argc << endl;
exit(1);
}

// json input file pointer
shared_ptr<Json::Value> jsonInput = make_shared<Json::Value>();
// json input file pointer
shared_ptr<Json::Value> jsonInput = make_shared<Json::Value>();

bool ok = jsonToCsv(jsonInput, argv[1], argv[2]);
if(!ok)
{
cout << "json to csv failed";
exit(1);
}
bool ok = jsonToCsv(jsonInput, argv[1], argv[2]);
if (!ok)
{
cout << "json to csv failed";
exit(1);
}

objects_t objects = jsonToDicts(jsonInput);
objects_t objects = jsonToDicts(jsonInput);

shared_ptr<lines_t> csv = dictsToCsv(objects);
shared_ptr<lines_t> csv = dictsToCsv(objects);

ofstream ofs;
ofs.open(argv[2]);
for(const auto&e : *csv)
ofstream ofs;
ofs.open(argv[2]);
for (const auto& e : *csv)
{
int len = e.get()->size();
int counter = 0;
for (const auto& g : *e)
{
int len = e.get()->size();
int counter = 0;
for(const auto&g : *e)
{
// write for all json columns in input json file
ofs << *g << (counter < len-1?",":"");
counter++;
}
ofs << "\n";
// write for all json columns in input json file
ofs << *g << (counter < len - 1 ? "," : "");
counter++;
}
ofs.close();
ofs << "\n";
}
ofs.close();

return 0;
return 0;
}

0 comments on commit 9887269

Please sign in to comment.