file-io

How do I save a matrix of integers to a text file in Matlab?

I have a 2D matrix myMatrix of integers which I want to save its content to a text file. I did the following: save myFile.txt myMatrix -ASCII I get this message: Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'myMatrix' not written to file. and nothing is written. What to do? ...

Cocoa Createfileapath

hello, I am trying to create a file on mac os. the data from the file will be accessed by the app. but how to create a file having read permission on all accounts. Currently the app can read data in admin account only. I am using following syntax: BOOL B = [fm createFileAtPath:p1 contents:data attributes:nil]; is it something to do w...

Sensible line buffer size in C?

I'm using popen to read output from shell commands. I will use fgets to read line by line. My question is how to choose the best buffer size for my char* buffer? I remember from a professor telling us to include <limits.h> and use LINE_MAX for such things. It works fine on my Mac, but there's no LINE_MAX on Linux. This mailing list arch...

Optimize PHP for Serving All Files (And Not Apache)

I have a need to send all requests for any web resource through PHP for user authentication purposes, and to not serve any files directly through Apache. Here's my .htaccess: # All requests are routed to PHP (images, css, js, everything) RewriteRule ^(.*)$ index.php?query=$1&%{QUERY_STRING} [L] I then process the request, verify the u...

php - sort from the end to the beginning

hi, i have a text (text.txt) file like this: shir beer geer deer i have also a php page with that source: <?php foreach (glob("*.txt") as $filename) { $file = $filename; $contents = file($file); $reverse = array_reverse($file, true); $string = implode("<br>" , $contents); echo $string; echo "<br></br>"; } ...

How do I refresh a file's thumbnail in Windows Explorer?

Our Windows file server has an archive service installed that "stubs" files that have not been accessed for a defined period of time. When a request for the stubbed file is sent to the server, the archive service replaces the stub with the original document and serves it to the user. A major complaint about the archive service was that ...

Better way, than this, to rename files using Python

Hello, I am python newbie and am still discovering its wonders. I wrote a script which renames a number of files : from Edison_03-08-2010-05-02-00_PM.7z to Edison_08-03-2010-05-02-00_PM.7z "03-08-2010" is changed to "08-03-2010" The script is: import os, os.path location = "D:/codebase/_Backups" files = os.listdir(location) for old...

file manipulation

in c++ i have written a simple program, which accepts 4 to 6 records and then do not accept any more when airline_no is same i.e. 1? The source code is: #include<fstream.h> #include<conio.h> #include<dos.h> #include<string.h> #include<stdlib.h> #include<process.h> #include<stdio.h> int lno; struct airln {int airline_no,routeno,dep_time,...

How to merge efficiently gigantic files with C#

I have over 125 TSV files of ~100Mb each that I want to merge. The merge operation is allowed destroy the 125 files, but not the data. What matter is that a the end, I end up with a big file of the content of all the files one after the other (no specific order). Is there an efficient way to do that? I was wondering if Windows provides...

C++ append to string and write to file

Why does the following code not work #include <iostream> #include <fstream> #include <stdio.h> #include <string.h> #include <stdlib.h> using namespace std; int main(){ string data; int i=0; while(i <= 5){ i++; data += i; data += "\n"; } ofstream myfile; myfile.open ("data.txt"); myfile <<...

how to prevent external xml file modification?

Hi guys, I'm coding a little library which will handle xml files to store some data, and I need this data to be handled only by the methods I provide in my library. I know that xml is readable for both human and machine, and that if somebody really wants to modify the xml file he'll probably do it, so... do any of you have an idea that ...

QFile open file on a shared drive

I have the following: Q_ASSERT(QFile::exists("\\.host\Shared Folders\username On My Mac\Desktop\New Deck.txt")); The file is picked from QFileDialog but when check if it exists with QFile::exists it returns FALSE; Is there any reason why QT cannot open a file on a shared drive. Btw, this path is a valid one on Windows and is generat...

Java NIO vs DotNet IO Performance

Hi, Does anyone know what the performance difference is between Java NIO vs DotNet IO performance. Reading this question, it seems that standard Java-IO and DotNet-IO have very similar IO performance. What is interesting to me is that the Java guys state that mass file copying, file server based operations...etc should be a lot quic...

How to read lines from a file in python starting from the end.

hello, I need to know how to read lines from a file in python so that I read the last line first and continue in that fashion until the cursor reach's the beginning of the file. Any idea's? ...

Java random selection of lines in csv file for output

I want to read in a variable length csv file and randomly select a percentage of lines from the file to be output. For instance if I have 20 lines I would read each line in counting up to 20 the last line will have a number only (the percentage). then figure this percentage from the number of lines read in for instance 10 on the last lin...

Read/Write File vs. Query Database

My website has a large number of readers every day. I wanted to track the traffic of each article. For each visitor, I added a unit on the counter. I'm confused between two solutions: Saved to a file on the server. Create the cron jobs to update them on the database. Save directly to database. Should I do now? ...

Replacing file content in PHP

I need a function just like preg_replace but instead of strings I need it to work with files / file content. ...

OpenMP and File I/O

I'm doing some time trials on my code, and logically it seems really easy to parallelize with OpenMP as each trial is independent of the others. As it stands, my code looks something like this: for(int size = 30; size < 50; ++size) { #pragma omp parallel for for(int trial = 0; trial < 8; ++trial) { time_t start, end; ...

File.createTempFile create special file or how to force flush data to harddrive?

Hi, I'm using File.createTempFile to create regular files I want to keep, the reason I use this method is because it guarantees a unique file name. However I'm seeing a strange thing with files created by this method: After I flush and closed the output stream on this file, I crash the machine running JVM deliberately, I assumed since t...

file rewriting with boost?

I would like to avoid using CreateFileMapping/MapViewOfFile to rewrite part of a file. Does boost provide this functionality? ...