text-files

Writing the results of Weka classifier to file in Java

孤街浪徒 提交于 2019-12-24 18:34:52
问题 I am generating decision trees in Weka in Java code as follows: J48 j48DecisionTree = new J48(); Instances data = null; data = new Instances(new BufferedReader(new FileReader(dt.getArffFile()))); data.setClassIndex(data.numAttributes() - 1); j48DecisionTree.buildClassifier(data); Can I save the results of the Weka results buffer to a text file in the program, such that the following can be saved at run-time to a text file: === Stratified cross-validation === === Summary === Correctly

Merging two files in Notepad

独自空忆成欢 提交于 2019-12-24 17:46:07
问题 Hi i have two long files both 30k lines long. Is there any way of merging them like that in Notepad++ or using other software? 1st line from 1st file: 1st line from second file 回答1: Here is a possible solution using Excel: 1.) Open the first file with Excel (all the text should be in one column) 2.) Open the second file with Excel (all the text should be in one column) 3.) Go back to your first file and add a : to every row of the second column 4.) Copy the first column of the second file and

Android in Eclipse - Invoke File Writer class in Background

◇◆丶佛笑我妖孽 提交于 2019-12-24 15:54:43
问题 When I click the button (btnPrintTardy) I need to generate a .txt file of whatever i have entered into a txtbox (editText1). This is my File Writer java class. import android.app.Activity; import java.io.*; import android.os.Bundle; import android.view.*; import android.widget.*; public class FileWriter extends Activity { EditText txtData; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); txtData = (EditText) findViewById(R.id.editText1); } public

Batch counting number of lines of text file without blank

早过忘川 提交于 2019-12-24 13:53:03
问题 I got two text files with different formats,let says i already have known there are 4 non-empty lines in the file,shown below (1st is valid, 2nd is invalid). AAA BBB CCC END (Blank line) (Blank line) AAA BBB (Blank line) CCC END Any "for loop" implementations/ways to distinguish 1st file has 4 non-empty lines which can tell it's valid and 2nd file has a extra blank line in the middle which can tell it's invalid. Because i got a for loop code which can count non-empty line number,applying that

Deleting a specific word from a file in python

江枫思渺然 提交于 2019-12-24 13:19:06
问题 I am quite new to python and have just started importing text files. I have a text file which contains a list of words, I want to be able to enter a word and this word to be deleted from the text file. Can anyone explain how I can do this? text_file=open('FILE.txt', 'r') ListText = text_file.read().split(',') DeletedWord=input('Enter the word you would like to delete:') NewList=(ListText.remove(DeletedWord)) I have this so far which takes the file and imports it into a list, I can then delete

How to read and organize text files divided by keywords

爷,独闯天下 提交于 2019-12-24 12:51:08
问题 I'm working on this code (on python) that reads a text file. The text file contains information to construct a certain geometry, and it is separated by sections by using keywords, for example, the file: *VERTICES 1 0 0 0 2 10 0 0 3 10 10 0 4 0 10 0 *EDGES 1 1 2 2 1 4 3 2 3 4 3 4 contains the information of a square with vertices at (0,0), (0,10), (10,0), (10,10). The "*Edges" part defines the connection between the vertices. The first number in each row is an ID number. Here is my problem,

BeautifulSoup on multiple .html files

偶尔善良 提交于 2019-12-24 10:53:31
问题 I'm trying to extract information between fixed tags with BeautifulSoup by using the model suggested here enter link description here I have a lot of .html files in my folder and I want to save results obtained with a BeautifulSoup script into another folder in the form of individual .txt files. These .txt files should have the same name as original files but would contain only extracted content. The script I wrote (see below) processes files successfully but does not write extracted bits out

Deny reading part of a file in python

烈酒焚心 提交于 2019-12-24 10:51:31
问题 I have a text file for which I use two write functions: 1) Normal Write, 2) Secure Write. Now when I want to read the data from the file, I should be only be able to read the data written using the "Normal Write" function and should not be able to read the data written using "Secure Write" function. My idea was to use a dictionary for this using the key as a flag to check if the value was written using normal write or secure write. How can I do this in Python? 回答1: its all a matter of how

Split output to populate nested dictionary python

坚强是说给别人听的谎言 提交于 2019-12-24 10:27:30
问题 I am trying to populate a nested dictionary, but are having trouble since I am fairly new to python (also to Stack Overflow). I have a txt file with paths to photos and I would like to populate the splits from it to a nested dictionary. An example of the text file looks like this: /photos/Bob_January_W1_001.png /photos/Alice_April_W2_003.png Where Bob is the user, January is the month, W1 the week and 001 the nr of the photo. Etc. I would like to populate a nested dictionary in the following

Find and extract text from within existing text file

妖精的绣舞 提交于 2019-12-24 10:23:09
问题 I need to be able to extract data from within an existing text file. The structure of the text file looks something like this... this line contains a type of header and always starts at column 1 this line contains other data and is always tabbed in this line contains other data and is always tabbed in this line contains other data and is always tabbed in this line contains other data and is always tabbed in this line contains other data and is always tabbed in this line contains other data