text file

  • Thread starter Siboniso Shangase
  • Start date
S

Siboniso Shangase

Hi
i m very new to python and i need hepl plz!!

i want to type this data in a text file it the same the diffrence is
the number that only increase and i canot write this up myself since
it up to 5000 samples

Data\ja1.wav Data\ja1.mfc
Data\ja2.wav Data\ja2.mfc
Data\ja3.wav Data\ja3.mfc
Data\ja4.wav Data\ja4.mfc
..
..
..
..
Data\ja(n).wav Data\ja(n).mfc

Data\ma1.wav Data\ma1.mfc
Data\ma2.wav Data\ma2.mfc
Data\ma3.wav Data\ma3.mfc
Data\ma4.wav Data\ma4.mfc
..
..
..
Data\ma(n).wav Data\ma(n).mfc
 
M

MRAB

Hi
i m very new to python and i need hepl plz!!

i want to type this data in a text file it the same the diffrence is
the number that only increase and i canot write this up myself since
it up to 5000 samples

Data\ja1.wav Data\ja1.mfc
Data\ja2.wav Data\ja2.mfc
Data\ja3.wav Data\ja3.mfc
Data\ja4.wav Data\ja4.mfc
.
.
.
.
Data\ja(n).wav Data\ja(n).mfc

Data\ma1.wav Data\ma1.mfc
Data\ma2.wav Data\ma2.mfc
Data\ma3.wav Data\ma3.mfc
Data\ma4.wav Data\ma4.mfc
.
.
.
Data\ma(n).wav Data\ma(n).mfc
This should give you a start:

path_of_samples_file = "samples.txt"

with open(path_of_samples_file, "w") as samples_file:
for index in range(1, 101):
samples_file.write("Data\\ja{0}.wav
Data\\ja{0}.mfc\n".format(index))
 
J

John Gordon

In said:
i want to type this data in a text file it the same the diffrence is
the number that only increase and i canot write this up myself since
it up to 5000 samples
Data\ja1.wav Data\ja1.mfc
.
.
Data\ja(n).wav Data\ja(n).mfc
Data\ma1.wav Data\ma1.mfc
.
Data\ma(n).wav Data\ma(n).mfc

This is a simple python program to do what you want:

samples = 5000
for i in range(1, samples):
print "Data\\ja%d.wav Data\\ja%d.mfc" % (i, i)
for i in range(1, samples):
print "Data\\ma%d.wav Data\\ma%d.mfc" % (i, i)

Replace the number 5000 with however many repetitions you want. (The
loop will stop at one less than the number, so if you want 5000 exactly,
use 5001.)

Then run the program like this from your command line:

python samples.py > textfile

And it will save the output in "textfile".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top