Is there a Python class that wraps the file interface (read, write etc.) around a string? I mean something like the stringstream classes in C++.
I was thinking of using it to redirect the output of print into a string, like this
sys.stdout = string_wrapper()
print "foo", "bar", "baz"
s = sys.stdout.to_string() #now s == "foo bar baz"
...
If I setup a CRON that runs a PHP script that in turn moves a file from one server to another, what would be the best way? Assume I have been given the proper username/password , and the protocol (like SFTP) is only prohibited if the language can't support it. I'm really open to options here -- these are XML files that hold order export ...
I'm wondering if it is possible to add methods in main program to an existing class defined in header file.
For example:
There is class CFun defined in file CFun.hpp, but in our party.cpp we want to add a method void hello() {cout << "hello" << endl;};without editing CFun.hpp
Obviously (unfortunately) construction:
#include "CFun.hpp"
...
I have a makefile template to compile a single DLL (for a plugin system).
The makefile of the user looks like this:
EXTRA_SRCS=file1 file2
include makefile.in
In the makefile.in I have:
plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS))
Where plugin.os is the main C++ file to be compiled. Btw, the files ending is .os are the ob...
I am updating a VBA program (excel). At startup the program checks if it can find a directory which is on the office fileserver using:
FileSystemObject.FolderExists("\\servername\path")
If this is not found the program switches to offline mode and saves its output to the local hard disk (for later transfer), instead of directly to the...
I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example,
this is the token 9,999,999.99
So here's is how I am approaching this problem. After a little analysis...
I'm experiencing a strange issue where my Visual Studio 2005 C++ program crashes the first time it runs after a new build. I'm having a difficult time debugging this intermittent issue and I suspect it's somehow related to a file somewhere on my hard drive that is being changed. If I can find the file(s), that might provide some more i...
Hi,
When I write to the beginning of the file,it always leaves the first line empty,and start writing from the second one.
How can I make it write from the first line,including the first one and on?
Thanks.
...
What are the API calls to copy a file that is currently locked. I'm hoping to be able to use .Net, but Win32 calls would be fine as well.
Please feel free to chime in about the same functionality on Unix, or any other OS.
...
I have a file and I don't know how big it's going to be (it could be quite large, but the size will vary greatly). I want to search the last 10 lines or so to see if any of them match a string. I need to do this as quickly and efficiently as possible and was wondering if there's anything better than:
s = "foo"
last_bit = fileObj.readl...
I currently have 2 BufferedReaders initialize on the same text file. When I'm done reading the reading the text file with the first BufferedReader, I use the second one to make another pass thru the file from the top. Multiple passes thru the same file are necessary.
I know about reset(), but it needs a previous call to mark() and mark...
How to put a File path control in VBA front panel? I want the user to be able to select the browse button and select the file path rather than putting up dialog boxes all over the place. I need the user to select three or more file paths.
...
Ok, I am importing and parsing csv files in a C# app. I started out doing a simple ReadLine() and splitting on commas but it turns out some of the text fields have commas in them. So I started to roll my own splitting function. Fortunately, it was only a few minutes before the "Hey stupid, someone's probably already done this?" light c...
FILE * __cdecl _getstream
I'm calling an fopen and it keeps crashing.
AfxMessageBox("getting here 1");
FILE * filePtr = fopen(fileName, ("rb") );
AfxMessageBox("getting here 2");
For some reason I never get to the second messagebox.
What makes it more interesting is that in debug mode the app works perfectly.. Most frustrating..
...
I'm writing a small agent in java that will play a game against other agents. I want to keep a small amount of state (probably approx. 1kb at most) around between runs of the program so that I can try to tweak the performance of the agent based upon past successes. Essentially, I will be reading a small amount of data at the beginning of...
Hi,
I just wanted to know your experience with using resharper.
We have a very heavy dbml file as our database has many tables and every time I need to open up that file I start getting lots of exception coming from resharper. Has anyone had that problem before? If yes, what did you do to fix this very ANNOYING problem !?!?
Thanks !
An...
Hi,
I have the following file/line:
pc=1 ct=1 av=112 cv=1100 cp=1700 rec=2 p=10001 g=0 a=0 sz=5 cr=200
pc=1 ct=1 av=113 cv=1110 cp=1800 rec=2 p=10001 g=0 a=10 sz=5 cr=200
and so on.
I wish to parse this and take the key value pairs and put them in a structure:
struct pky
{
pky() :
a_id(0),
sz_id(0),
cr_id(0),
...
Hi, another request sorry..
Right now I am reading the tokens in one by one and it works, but I want to know when there is a new line..
if my file contains
Hey Bob
Now
should give me
Hey
Bob
[NEW LINE]
NOW
Is there a way to do this without using getline?
...
What is the best way to find the total number of words in a text file in Java? I'm thinking Perl is the best on finding things such as this. If this is true then calling a Perl function from within Java would be the best? What would you have done in condition such as this? Any better ideas?
...
Hello all,
I’m currently using the OpenNETCF.Desktop.Communication.dll to copy files from my desktop to a CE device, but I keep getting an error:
‘Could not create remote file’
My development environment is VS2005 (VB.NET)
My code:
ObjRapi.Connect()
ObjRapi.CopyFileToDevice("C:\results.txt", "\results.txt")
ObjRapi.Dispose()
ObjRapi...