-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcsv-to-txt.cpp
66 lines (53 loc) · 943 Bytes
/
csv-to-txt.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<fstream>
using namespace std ;
#define INPUT_FILE "input.csv"
int show_file_content() ; // Prints input file contents on the console
int main()
{
show_file_content() ;
return 0 ;
}
int show_file_content()
{
ifstream A ;
ofstream B ;
int rows = 1 ;
char c ;
A.open( INPUT_FILE, ios :: binary ) ;
B.open( "output.txt", ios :: out | ios :: trunc ) ;
if( !A )
cout << "\n Error in opening file" ;
else
{
while( A )
{
c = A.get() ;
if( c != EOF )
{
// New line condition
if( c == '\n' )
{
cout << "\n" ;
B << '\n' ;
}
// Comman condition
else if( c == ',' )
{
cout << " " ;
B << ' ' ;
}
// Default condition
else
{
cout << c ;
B << c ;
}
}
}
A.close() ;
B.close() ;
}
}