Autor Beitrag
Dhakiyah
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Mo 02.11.09 13:52 
Hallo!
Ich komme nicht weiter.
Ich habe eine Textdatei in der ne Menge Daten stehen, mit Komma getrennt.
Jetzt muss ich halt zum Beispiel nach 10 Kommas kucken ob da ein Datumsformat kommt und dann die Datei verändern bzw. to_date.... einfügen.
Und danach weiter.
In der Datei gibt es 4 Datumsformate die evtl. geändert werden müssen. Wenn null kommt bleibt es so wenn ein Datum kommt muss ich es in to_date.... ändern.

Habe mal angefangen, aber irgendwie...

ausblenden volle Höhe Delphi-Quelltext
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:
var f_file, f_neu: textfile;
i_pos, i, j: integer;
s_zeile: string;
s_zeile_neu, s_zeichen: string;
begin
  assignfile(f_file, 'd:\abwesenheit.sql');
  assignfile(f_neu, 'd:\abwesenheitneu.sql');
  reset (f_file);
  rewrite (f_neu);
  while not eof(f_file) do
  begin
    readln(f_file,s_zeile);
    s_zeile_neu := copy (s_zeile, 0313) + 'to_date(''' + copy (s_zeile, 31420) +
                   ',''yyyy-mm-dd'')';

    i_pos := 335;
    s_zeichen := copy(s_zeile, i_pos, 1);
    if s_zeichen = 'n' then
    s_zeile_neu := s_zeile_neu + copy(s_zeile, 3345)
    else
      s_zeile_neu := s_zeile_neu + ',to_date('''+ copy(s_zeile, 33620) +
                   ',''yyyy-mm-dd hh24:mi:ss'')' ;
    j := 0;
    for I := i_pos to length(s_zeile) do
      begin
        if s_zeile[i] = ',' then inc (j);
        if j = 8 then
        begin
          i_pos:= i+1;
          j := 10;
        end;
      end;
    s_zeile_neu := s_zeile_neu + ',' + copy(s_zeile, 340, i_pos-340);
 
    writeln(f_neu, s_zeile_neu);
  end;
  closefile(f_neu);
  closefile(f_file);
end;


Ich frage mich halt wie ich den String immer weiter laufen lasse. Also weiter die , zählen... Und dann gegebenenfalls ändern...


Moderiert von user profile iconNarses: Topic aus VCL (Visual Component Library) verschoben am Mo 02.11.2009 um 14:43

_________________
Es ist soooo flauschig !!!
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Mo 02.11.09 14:18 
Index von Copy beginnt bei 1 :P ;)
uko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 220
Erhaltene Danke: 1

Win XP, VISTA, WIndows 7
Delphi 2007/2010 Prof
BeitragVerfasst: Mo 02.11.09 14:27 
Poste doch mal 3-4 Beispielsdatensätze und gib dort an, was Du wo ersetzen willst (hab nämlich grad Probleme, deinen Code mit der Beschreibung in Einklang zu bringen).


Grüße,
Uli