Selamlar,

Elimde yuzlerce .dat dosyasi var ve benim bu dosyalardaki ilk 3 satiri silmem gerekiyor. Arta kalan python kirintilari ve google vasitasiyla su noktaya kadar geldim ama ilerlemiyor.
Ekran goruntusu: ibb.co

Yardimci olabilirseniz sevinirim. Tesekkurler!

title_main=input("please enter the main part of the data file title")
title_start=input("please enter what is the starting number of data")
title_finish=input("please enter what is the finishing number of data")
title_start=int(title_start)
title_finish=int(title_finish)

for title_name in range(title_start, title_finish):
title_start=str(title_start)
title_finish=str(title_finish)
title_name=title_main + title_start + ".dat"
a_file = open(title_name, "r")
thenumber=thenumber+1 #get list of lines

lines = a_file.readlines()
a_file.close()

del lines[1] #delete lines


new_file = open(title_name, "w+") #write to file without line

for line in lines:
new_file.write(line)

new_file.close()

title_start=int(title_start)
title_finish=int(title_finish)
thenumber=int(thenumber)
thenumber=title_start+1
else:
print("done")


UYARI:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-13-5534c6203368> in <module>
9 title_finish=str(title_finish)
10 title_name=title_main + title_start + ".dat"
---> 11 a_file = open(title_name, "r")
12 thenumber=thenumber+1 #get list of lines
13

FileNotFoundError: [Errno 2] No such file or directory: 'REF_in_situ_197844.dat'

 

Dosya yolunda problem olabilir. Direkt C:\\Users\ vs seklinde dosya yolunu yazip acmaya calisabilirsin.

j r r tolkien hayrani

Tüm dosyalarını yedekle
Alttaki python dosyasını tüm dosyaların olduğu klasör içinde oluştur.
Dosyayı çalıştır.
Ardından orjinal dosyaları sil.
ardından bulunduğun klasör directory si içinde command shell çalıştır ve şu komudu yaz: rename *.dat0 *.dat


pastebin.com

sttc

Cok tesekkurler sttc!
Kendi malligimdan biraz zaman aldi ama super calisiyor.

ferishtah
1

mobil görünümden çık