I've 3 .txt files. I want to perform and operation to these 3 text files and to save the output in a new text file.
fid = fopen(AND('a.txt','b.txt','c.txt'));
will this work as per my requirements? but i want to save in a new text file, how can i go for it?
For example my a.txt file contents are
DSC01605.bmp
Hampi8.bmp
DSC01633.bmp
DSC01198.bmp
DSC01619.bmp
similarly some images are present in b.txt file, and hence in c.txt file. I just want to get similar image names out of those files which are saved in above text files, and want to save in a separate new text file.
Related
I need to save several files like pdf, docx, xslx etc..
I also need to make full text search on that files, for example, file named test.pdf that contains three lines:
firt test line
two my test line
three test line
Given an input like 'my' i need to extract file test.pdf
Can i do it with mongoDB or other tools (aws, alfresco?) ?
I have a list with several .rtf files ("file_withPath") containing PNG or JPG images inside them. I would like to copy the file contents and paste all images in a newly created file called "package.rtf". Unfortunately, with the several methods I have used to do this problem, it keeps rewriting the output file each time through the loop. I only see the final PNG that was copied and pasted instead of all of them pasted sequentially.
Code:
list1.append(file_withPath)
for item in list1:
outfile = open(r"C:\Users\3\Desktop\collection\package.rtf", "w")
shutil.copyfileobj(open(item, "r"), outfile)
I have a group of .dat files I need to convert to .txt files. I have a directory called "data" that has "210" files (0.dat, 1.dat, ......210.dat), I want to convert these .dat files to .txt files (0.txt, 1.txt ......210.txt), the data type is 16bit integer.
Ideally you are supposed to try a few steps before coming here asking for a solution. Since this is your first post, I'll give you a few pointers. Next time please Google a few solutions. Try them. Post your code/error if you have any issues to receive help.
From the directory, Load all the contents of the folder using,
files = dir('*.dat');
Add a FOR loop to read each dat file one by one.
fileID = fopen('XXXX.dat');
OneByte = fread(fileID,'*uint16');
Then once the file is loaded you can convert it into .txt file.
At the moment I have working code that can read multiple .log files and create a giant .txt file which contains all their data. Then I simply read the giant .txt file. However, this code is inefficient because it involves writing a new .txt file every time I want to run the script.
Does someone know how to simplify this so that it doesn't write a new .txt file every time? Ideally by creating a 'virtual' .txt file?
files=dir('IndividualFiles.*.log');
fileout='GIANT.txt';
fout=fopen(fileout,'w');
for cntfiles=1:length(files)
fin=fopen(files(cntfiles).name);
temp = fread(fin,'uint8');
fwrite(fout,temp,'uint8');
fprintf(fout,'\n');
fclose(fin);
end
fclose(fout);
filename = 'C:\Users\myname\Desktop\Learning Documents\myfolder\GIANT.txt';
How can I either delete the contents of a .txt file so that it becomes a blank file or it deletes the file altogether? I'm reading in from the .txt file and if I don't delete the contents from the previous time it ran, it will omit results that I want to account for.
Suppose your file is named to_be_deleted.txt, you can simply use the following command to delete the file altogether:
delete 'to_be_deleted.txt';
On the other hand, if you simply want to clear it's contents, just open it using fopen with the write attribute as follows:
fopen('to_be_deleted.txt','w');