I have total 1000 txt files which are filled with data. I have copied all of them into a single txt file and have loaded it into my python code as:
data = numpy.loadtxt('C:\data.txt')
This is fine up to this point. Now, what I need is to select every 5th file from those 1000 txt files (i.e. 200 files) and load their combined content into a single variable. I am confused about how to do this.
Need help.
Why not load the files one at a time (assuming the files are
data-0000throughdata-0999):Then you can get every fifth file with:
every_fifth_file = datasets[::5]. See also: Explain Python's slice notation