textfiles

Python: load words from file into a set

Hello, I have a simple text file with several thousands of words, each in its own line, e.g. aardvark hello piper I use the following code to load the words into a set (I need the list of words to test membership, so set is the data structure I chose): my_set = set(open('filename.txt')) The above code produces a set with the follo...

How to insert a text file into a field in PostgreSQL?

How to insert a text file into a field in PostgreSQL? I'd like to insert a row with fields from a local or remote text file. I'd expect a function like gettext() or geturl() in order to do the following: % INSERT INTO collection(id, path, content) VALUES(1, '/etc/motd', gettext('/etc/motd')); -S. ...

Generating random number in a given range in Fortran 77

I am a beginner trying to do some engineering experiments using fortran 77. I am using Force 2.0 compiler and editor. I have the following queries: How can I generate a random number between a specified range, e.g. if I need to generate a single random number between 3.0 and 10.0, how can I do that? How can I use the data from a text f...

Section Delimiting for Flat Files

I need to generate a flat file with several different sections, each with different record structures. All data is delimited text, single line per record. What would be a good delimiting sequence, or mechanism to differentiate sections, given that records can contain line feeds etc. within quoted text fields? ...

How can I write the same text to two separate file handles using Perl?

I need to output the same text to two different files (it is a application requirement, which I am testing). Now, I do not wish to open two file handles, write two lines to each, then close them a dozen times in my code. Is there a simple way, perhaps using a single line in Perl (but not in the CLI!), to send the same text to two differ...

Saving a text file to a SQL database without column names

Hello, I am reading a text file in C# and trying to save it to a SQL database. I am fine except I don't want the first line, which is the names of the columns, included in the import. What's the easiest way to exclude these? The code is like this while (textIn.Peek() != -1) { string row = textIn.ReadLine(); string[] columns = r...

Best way to retrieve variable values from a text file - Python - Json

Referring on this question, i have a similar -but not the same- problem.. On my way, i'll have some text file, structured like: var_a: 'home' var_b: 'car' var_c: 15.5 And i need that python read the file and then create a variable named var_a with value 'home', and so on. Example: #python stuff over here getVarFromFile(filename) #t...

How do you save data to a text file in a given format?

I want to save a matrix to a text file, so I can read it by another program. Right now I use: save('output.txt', 'A','-ascii'); But this saves my file as 6.7206983e+000 2.5896414e-001 6.5710723e+000 4.9800797e-00 6.3466334e+000 6.9721116e-001 5.9975062e+000 1.3346614e+000 6.0224439e+000 1.8127490e+000 6.3466334e+000 2.0517928e+...

How do text differencing applications work?

How do applications like DiffMerge detect differences in text files, and how do they determine when a line is new, and not just on a different line than the file being checked against? Is this something that is fairly easy to implement? Are there already libraries to do this? ...

vba - Read lines from text file - Exclude top two lines?

Hi, I've got this macro code in Microsoft Office Word 2003 which reads the lines of a text file. The lines each represent a string value that I need to use later in the code. However, the first two lines of the text file contains some stuff that I don't need. How can I modify the code so that it skips the two first lines? The "intellis...

Creating a new .txt file with date in front, C#

Hey all. I am trying to get the following: [today's date]___[textfilename].txt from the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication29 { class Program { static void Main(string[] args) { WriteToF...

vba - Word - Error in macro, trying to insert values into bookmarks

Hi, I'm trying to write a Word macro which inserts data from the Current User in Registry into predefined bookmarks in the document. I've got an ini-file which dictates what the names of each registry entry is, and that value is then imported into a loop in the Word Macro. This works fine (I think), but the Word macro needs to insert the...

Vba - On error doesn't work? Reading registry value

Hi, this is strange, I've got a macro with an array containing several registry keys. And I want to insert the values of these into predefined bookmarks in a Word document. This works great if the key is there, but if it isn't, I want the code to skip that and continue trying the next one in the array. I've got the code that looks l...

How do I write to a text file outside of the document root in Rails?

I want to a list of emails in a text file outside of my repository and doc root in ROR. But I need the application to write to it. What is the best way to accomplish this? My guess is a sym link but I'm not sure. I am also curious about where I should keep this text file. It is a list of emails to invite people to use my service. Th...

Text printing in landscape via notepad

I'm trying to do some text-based printing on Windows. My program makes use of windows' "notepad /p file.txt" functionality that prints a text file on the default printer. The problem is that you cannot say that you want to print in landscape instead of portrait. In the same way, it's not possible to print to another printer. Some backg...

javascript text compression/decompression

Suppose I have a 400K text file which I want to read from a javascript. The problem is, my target audience have a slow connection, so 400k might take too long to load. I suppose I need to compress the file, but well, how can I decompress it via javascript on the client side? Is it worth it, or will the time needed for decompression neg...

Is it possible to show the contents of a text file in Crystal Reports.

I have a crystal report which contains a list of absolutely referenced text files. There is one text file referenced in each body line. e.g. line1 c:\file1.txt line2 c:\file2.txt Is there any way to display the contents of these files in Crystal? i.e. I would like each crystal body line to show the text from the referenced ...

C# Read Text File Containing Data Delimited By Tabs

I have some code: public static void ReadTextFile() { string line; // Read the file and display it line by line. using (StreamReader file = new StreamReader(@"C:\Documents and Settings\Administrator\Desktop\snpprivatesellerlist.txt")) { while ((line = file.ReadLine()) != null) ...

EOF marker when generating text files?

When I'm generating a text file programatically, should I insert the ASCII EOF marker (decimal value 26) at the end of the file? Do the .NET Programming Languages do this automatically? ...

I need to save a String to a text file using Java

I am a beginner Java programmer. I am attempting to make a simple text editor. I have got the text from the text field into a variable that's a String, called "text". My question is, how can I save the contents of the "text" variable to a text file? Thank you! ...