text-files

importing random words from a file without duplicates Python

久未见 提交于 2019-12-13 07:27:39
问题 I'm attempting to create a program which selects 10 words from a text file which contains 10+ words. For the purpose of the program when importing these 10 words from the text file, I must not import the same words twice! Currently I'm utilising a list for this however the same words seem to appear. I have some knowledge of sets and know they cannot hold the same value twice. As of now I'm clueless on how to solve this any help would be much appreciated. THANKS! please find relevant code

Warning: mysql_connect(): Access denied

若如初见. 提交于 2019-12-13 07:23:58
问题 i have this php function to read my dbinfo out of a textfile on my pc: function loaddb(){ $fh = fopen('dta.txt','r'); $line = fgets($fh); $_SESSION['dbname']=$line; $line = fgets($fh); $_SESSION['dbuser']=$line; $line = fgets($fh); $_SESSION['dbpass']=$line; $line = fgets($fh); $_SESSION['server']=$line; fclose($fh); }; and this code works. but when it returns my code into my session var i see it has added extra line breaks in the actual variable, so the result when i connect is Warning:

Sorting information from a file in python

拟墨画扇 提交于 2019-12-13 07:17:40
问题 I have a .txt file that has the following information in it that displays a users name and then 3 scores that they have scored in a quiz: callum,10,7,9 carl,10,10,10 hollie,1,4,7 brad,4,8,3 kyle,7,2,0 I would like to sort it into alphabetical order displaying the users highest score after their name. 回答1: Read file content. Use readlines() method to read lines from file. Use split() to get Name and score. Add in dictionary: Name is Key and Value is total score. Get all keys from the result

Editing a line in a text file using temp file C

痞子三分冷 提交于 2019-12-13 07:08:02
问题 I am trying to edit a line in a textfile but i have an unexpected behavior while i am editing the file. What i want to do is adjust a specific line (points : 100) of a text that looks like. In the function i pass arguments by value the new coins to be adjusted and the offset of the file with ftell->user_point. What i get as an output is weird. I try to copy the rest of the file to a temp,with an edited line, and then copy it back to the original file from the point that i copied to temp.

c, Import text file with different lines and handle the lines

岁酱吖の 提交于 2019-12-13 06:24:54
问题 im trying to make a little program that reads a chat log and calculates some numbers. Thing is im not sure what command to use since the lines arent identical. Heres a few lines from the log [22:56:37] Your strike was absorbed by a magical barrier! [22:56:37] You miss! [22:56:37] You attack Tylaia with your bright arcanium weighted bearded axe and hit for 70 (-41) damage! [22:56:37] You critical hit Tylaia for an additional 19 damage! [22:56:37] You hit Tylaia for 66 (-21) damage! [22:56:37]

Adding only specific text from a file to an array list [duplicate]

南楼画角 提交于 2019-12-13 06:04:20
问题 This question already has answers here : Adding only specific text from a file to an array list, part 2 - Java (2 answers) Closed 4 years ago . I hope I can get here some help. This is the text in my file: Name: John Name: Peter Name: Sarah Place: New York Place: London Place: Hongkong How can I for example only add the names from the text file in the following arraylist? So far, I've got... and it add everything in the arraylist, including places! private ArrayList<Name> names = new

The given key was not present in the dictionary in vb.net

浪尽此生 提交于 2019-12-13 05:42:28
问题 I'm getting this error in vb.net, when trying to connect to mysql database: An error occurred creating the form. See Exception.InnerException for details. The error is: The given key was not present in the dictionary. I'm reading the database information (user, password, host, database) from a textfile. Dim FILE_NAME As String = "D:\connection.txt" Dim objReader As New StreamReader(FILE_NAME) Public Sub textfileopener() host = objReader.ReadLine user = objReader.ReadLine password = objReader

Importing Multiple Text Files as Individual data.frames in R - 2.15.2 on Mac - 10.8.4

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 05:13:32
问题 I have searched through this forum for most of the day trying to find the solution - I could not find so I am posting. If the answer is already out there please point me in the right direction. What I have - A directory with 40 texts files called the following test_63x_disc_z00.txt *01.txt *02.txt ... *39.txt In each of these files there are 10 columns of data with no header and a varying number of rows. What I want - I want to have an individual data.frame in R for each text file with names:

Organizing Messy Notepad data

我只是一个虾纸丫 提交于 2019-12-13 04:26:36
问题 I have some data in Notepad that is a mess. There is basically no space between any of the different columns which hold different data. I know the spaces for the data. For example, Columns 1-2 are X, Columns 7-10 are Y.... How can I organize this? Can it be done in R? What is the best way to do this? 回答1: ?read.fwf may be a good bet for this circumstance. Set the path to the file: temp <- "\pathto\file.txt" Then set the widths of the variables within the file, as demonstrated below. #1-2 = x,

MATLAB uint8 data type variable save

╄→尐↘猪︶ㄣ 提交于 2019-12-13 04:23:58
问题 does anyone know how to save an uint8 workspace variable to a txt file? I tried using MATLAB save command: save zipped.txt zipped -ascii However, the command window displayed warning error: Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'zipped' not written to file. 回答1: In order to write it, simply cast your values to double before writing it. A=uint8([1 2 3]) toWrite=double(A) save('test.txt','toWrite','-ASCII') The reason uint8 can't be written is hidden in