You are on page 1of 2

Program BacaCSV;

uses sysutils;

{Procedure BacaTulisString(Var MyFile:text; filename, TextTmp: string);}

Begin
Assign(myFile, filename);
Reset (myFile);

writeLn('BACA DAN TULIS STRING DATA');

Repeat
Readln(myFile, TextTmp);
writeln(TextTmp);
Until Eof(myFile);

ReadLn;
end;

Procedure ConvertStringToInteger(Var MyFile:text; filename, TextTmp: string);


var
A: array of char;
DataInt: array
[1..10] of LongInt;
Tabel1:array[1..3] of integer;
Baris:integer;
len, I,J,k :Integer;
B: string;
Begin
Assign(myFile, filename);
Reset (myFile);
For Baris:=1 to 3 do Tabel1[Baris]:=0;

WriteLn; WriteLn('BACA STRING KEMUDIAN CONVERT KE INTEGER');

Repeat
I:=1; J:=1; DataInt[1]:=0;
Readln(myFile, TextTmp);
len:=length(TextTmp);
B:= TextTmp[1]+TextTmp[2];

repeat

if TextTmp[I] = ';' then


begin
J:= J+1 ;
dataInt[j]:=0;
end
else

DataInt[j]:=DataInt[J]*10+ strToInt(TextTmp[I]);

I:=I+1;
until I > len;

for k:= 1 to j do write (' ',DataInt[k]);


writeln;
B:='';
Until Eof(myFile);
Close (Myfile);
ReadLn;

end;

Var myFile: text;


Var FileName, TextTmp: string;

Begin
filename:= 'D:\stis\alpro\testdata.csv';
BacaTulisString(MyFile, filename, TextTmp);
ConvertStringToInteger(MyFile, filename, TextTmp);

End.

You might also like