I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to implement the solution in python.
I'm having trouble with the "replace" part of the solution. I've read the official csv module documentation a...
[Please note that this is a different question from the already answered How to replace a column using Python’s built-in .csv writer module?]
I need to do a find and replace (specific to one column of URLs) in a huge Excel .csv file. Since I'm in the beginning stages of trying to teach myself a scripting language, I figured I'd try to i...
I have a text file that contains a list of regexp's which I regularly use to clean html files according:
list.txt
<p[^>]*>|<p>
<\/?(font|span)[^>]*>|
<\/u>\s*<u>|
<\/u>\s*<i>\s*<u>|<i>
if each line consisted of the form "#{a}|#{b}", what would be the simplest way to both read and convert this file into the array:
[
[ /<p[^>]*>/, '...
Dear all,
I've been working in this small piece of code that seems trivial but still i cannot really see where is the problem. My functions does a pretty simple thing. Opens a file, copy its contents, replace a string inside and copy it back to the original file (a simple search and replace inside a text file then).
I didn't really know ...
I'm creating temporary file in java but i'm unable to delete it. This is the code I have written:
temp = File.createTempFile("temp", ".txt");
temp.deleteOnExit();
fileoutput = new FileWriter(temp);
buffout = new BufferedWriter(fileoutput);
...
Basically I need to serve files from a location that requires windows authentication. Instead of having my client's deal with it directly, I would like to implement a process so that they can simply download the files as if they were on my server, after they have logged in to my system, of course. Here is what I have so far, which does...
I'm using VB 2005, how do I open a CSV file and read the columns/rows and display the values in a datagrid?
CSV file example:
jsmith,[email protected]
I then want to perform an action on each row i.e. each user, how would I do this?
I'm a newbie as you can tell but happy to learn.
Thanks
...
Is there a built in method in .net for encoding file paths in the same way you would encode a url? For instance, if I have illegal characters in a file name, like "whatever:whatever" I would like it to encode the ":" so it's still there, just encoded so that the system will accept it. I'd like to do something like Path.Encode(fileName)
...
I am working on a (database-ish) project, where data is stored in a flat file. For reading/writing I'm using the RandomAccessFile class. Will I gain anything from multithreading, and giving each thread an instance each of RandomAccessFile, or will one thread/instance be just as fast? Is there any difference in reading/writing, as you can...
I am looking for an efficient way to create a file whose size is unknown but can range from mb's to gb's and fill its content randomly. I may write first 200 bytes than jump to the end and write last 200 bytes and move to the middle and write there. Is RandomAccessFile efficient for doing this or are there any alternatives better suited ...
Suppose a very simple program that lists out all the subdirectories name of a given directory. Sound simple enough? Except the only way to list all subdirectories in Java is to use FileameFilter combined with File.list().
This works for the trivial case, but when the folder has say 150,000 files and 2 sub folders, it's silly waiting th...
I'd like to be able to type quick, simple commands that manipulate files in-place. For example:
# prettify an XML file
format-xml foo | out-file foo
This won't work because the pipeline is designed to be "greedy." The downstream cmdlet acquires a Write lock to the file as soon as the upstream cmdlet processes the first line of input...
I am trying to save images using the following code:
- (void)writeData{
if(cacheFileName==nil)
return;
if(cacheDirectoryPath==nil)
return;
if (![[NSFileManager defaultManager] fileExistsAtPath:[self filePath]]) {
NSData *imageData = UIImageJPEGRepresentation(self.image, 0.9);
NSEr...
In Python, how do I read a binary file and loop over each byte of that file?
...
Ok this may seem like a bit of a noob question but one many Web developers I know dont have a full understanding of.
Basically how does a file uploading from a web page file input box to a webserver (hosting a .net site for example) with a FileUpload control's uploaded event?
My understanding was that a post was made to the server requ...
What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of doing this?
One solution is using the NSString method:
+ (id)stringWithContentsOfFile:(NSString *)path
encoding:(NSStringEncoding...
I'm writing arbitrary byte arrays (mock virus signatures of 32 bytes) into arbitrary files, and I need code to overwrite a specific file given an offset into the file. My specific question is: is there source code/libraries that I can use to perform this particular task?
I've had this problem with Python file manipulation as well. I'm l...
I have a very simple python script that should scan a text file, which contains lines formatted as id='value' and put them into a dict. the python module is called chval.py and the input file is in.txt. here's the code:
import os,sys
from os import *
from sys import *
vals = {}
f = open(sys.argv[1], 'r')
for line in val_f:
t = li...
I have one method that opens a file and passes off to another function to write some data to it. That second method wants to use PrintWriter to write its data. However, I didn't want to require that everybody use PrintWriter to write to that stream.
Currently it looks something like this ( sanitized example... don't bother criticizing m...
I'm having a very difficult time. I am running windows 2008 server, I have an Able Commerce site using ASP.NET with C#. I'm writing an automated task that will ftp some xml files down into a local directory on our web server and then the program parses the xml file and saves information to our database. The problem, once I save the files...