text-files

Server Side Include

倾然丶 夕夏残阳落幕 提交于 2019-12-06 14:34:27
Is it possible to use a server side include to access files that are outside of the server? If not what are some other options to do this? Use cURL to get data outside of the domain. If you want to then execute the data you receive, go ahead and eval() it. But, be forewarned that this will get the 'output' of the page. Meaning if it is an executed page like a '.php' page, you will get the data that comes out as a result of it being processed. <?php // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");

Can a C# program read a text file into memory and then pass that object to a method that requires a filename?

痴心易碎 提交于 2019-12-06 14:21:37
In a C# program I am importing a large text file (300mb) into a MySQL database via the MySqlBulkLoader function of the MySql .Net Connector. The import takes quite a long time and results in almost 100% disk usage on the Windows 2003 Server it is running on. In an attempt to speed up the import the program nows splits the big file into smaller chunks. Would it be possible to read the small file chunk (8mb) into memory (ie array) and then pass it to the MySQLBulkLoader as a file? The bulk loader looks for a filename path: MySql.Data.MySqlClient.MySqlBulkLoader myBulk = new MySql.Data

C# (sharp) reading random line from txt file [duplicate]

[亡魂溺海] 提交于 2019-12-06 13:20:24
This question already has answers here : Read random line from a file? c# (2 answers) Closed 6 years ago . Can anyone tell me how to read random line from txt file? I want to read random line from txt file and show only that line in textBox. Code examples would be great! Thanx in foward var lines = File.ReadAllLines(path); var r = new Random(); var randomLineNumber = r.Next(0, lines.Length - 1); var line = lines[randomLineNumber]; The simplest solution is to read all the lines to memory and pick one randomly. Assuming that all the lines can fit in memory. string[] allLines = File.ReadAllLines

How to read data in chunks from notepad file in Matlab?

空扰寡人 提交于 2019-12-06 12:20:12
My data is in following format: TABLE NUMBER 1 FILE: name_1 name_2 TIME name_3 day name_4 -0.01 0 364.99 35368.4 729.99 29307 1094.99 27309.5 1460.99 26058.8 1825.99 25100.4 2190.99 24364 2555.99 23757.1 2921.99 23240.8 3286.99 22785 3651.99 22376.8 4016.99 22006.1 4382.99 21664.7 4747.99 21348.3 5112.99 21052.5 5477.99 20774.1 5843.99 20509.9 6208.99 20259.7 6573.99 20021.3 6938.99 19793.5 7304.99 19576.6 TABLE NUMBER 2 FILE: name_1 name_5 TIME name_6 day name_7 -0.01 0 364.99 43110.4 729.99 37974.1 1094.99 36175.9 1460.99 34957.9 1825.99 34036.3 2190.99 33293.3 2555.99 32665.8 2921.99 32118

Read lines of a textfile and getting charmap decode error

北慕城南 提交于 2019-12-06 10:39:16
im using python3.3 and a sqlite3 database. I have a big textfile around 270mb big which i can open with WordPad in Windows7. Each line in that file looks as follows: term \t number\n I want to read every line and save the values in a database. My Code looks as follows: f = open('sorted.de.word.unigrams', "r") for line in f: #code I was able to read all data into my database but just to a certain line, i would suggest maybe half of all lines. Then im getting the following error: File "C:\projects\databtest.py", line 18, in <module> for line in f: File "c:\python33\lib\encodings\cp1252.py", line

Searching text files' contents with various encodings with Python?

谁都会走 提交于 2019-12-06 09:43:50
I am having trouble with variable text encoding when opening text files to find a match in the files' contents. I am writing a script to scan the file system for log files with specific contents in order to copy them to an archive. The names are often changed, so the contents are the only way to identify them. I need to identify *.txt files and find within their contents a string that is unique to these particular log files. I have the code below that mostly works. The problem is the logs may have their encoding changed if they are opened and edited. In this case, Python won't match the search

Android - reading a text file from Assets seems to include a LOT of junk before/after the actual data?

一世执手 提交于 2019-12-06 09:24:40
I package a text file with my Android App (in Assets) which I read within the App itself. To avoid this file being compressed, it's named 'mytestfile.mp3' and until recently, that worked just fine. In one of the recent SDK/ADT changes, it seems something 'odd' is happening when reading from Assets and I'm open to ideas as to what it is... I use code something like this AssetFileDescriptor descriptor = getAssets().openFd("mytextfile.mp3"); BufferedReader f = new BufferedReader(new FileReader(descriptor.getFileDescriptor())); String line = f.readLine(); while (line != null) { // do stuff Log.d(

How to import data with line breaks from text file into R?

断了今生、忘了曾经 提交于 2019-12-06 09:23:24
问题 I have a text file that I'd like to import into R . Problem is, the file looks like this: x1,x2,x3,x4,x5,x6,x7,x8,x9,10,x11 1953.00 7.40000 159565. 16.6680 8883.00 47.2000 26.7000 16.8000 37.7000 29.7000 19.4000 1954.00 7.80000 162391. 17.0290 8685.00 46.5000 22.7000 18.0000 36.8000 29.7000 20.0000 and so on. I tried > data <- read.table("clipboard", header=TRUE) but that didn't work. 回答1: While the data is ill-formed it still can be parsed given the following assumptions: The header defines

R: how to get information from a txt file with R

穿精又带淫゛_ 提交于 2019-12-06 07:48:58
R experts, I have a large text file, which has specific pattern and format. My text.txt contains x1 `xx`nkkna`yy`taktnaknvcaklrhkahnktn, altlkhakthakd`xx`nmm cataitha`yy`knkcnaktnhakt x2 `xx`ngkna`yy`taktnaknvcaklrhkahnktn, altlkhakthakdnmm cataithaknkcnaktnhakt x3 `xx`nkg,kna`yy`taktnaknvcaklrhkahnktn, altlkhakthakdnmm cataithaknk`xx`cna`yy`ktnhakt x4 nkkndataktnaknvcaklrhkahnktn, altlkhakthakdnmm cataithaknkcnaktnhakt Then, I want to ask R to find a list of words, in this case is x1, x2, x3 and x4 And inbetween, I want to get a list for each of them, that is between "xx" and "yy". As such,

Good ways to limit text log file

帅比萌擦擦* 提交于 2019-12-06 07:47:07
问题 I have a winForm app in which I have a text file for logging purpose. I want to limit its size to 10 MB so that if this limit is passed and new data is written then the oldest data in text file is deleted to make space for new data. any useful suggestion ? 回答1: Use some logging framework (I suggest NLog or log4net, both available from NuGet) which provides rolling log files feature. E.g. with log4net you can use following configuration to limit log file size to 10Mb <appender name=