Consider python please for this problem:
I did a python program to read the first 20 lines from a file and here is the code
holder = 20
lines = 3
file = "123456.pssm"
_file = ".txt"
while 1:
out_file = input("[OUTPUT] - Please enter the
name of file: ") + _file
if (not _file):
print("Filename not
specified - Please Try Again\n")
continue
break
with open(_file, "a") as e:
with open(file, "r") as f:
for num, line in
enumerate(f, 1):
if (line < num < holder + 1):
print(line.strip())
e.write(line.strip() + "\n")
print("Information saved to {}".format(_file))
What i need is change it to make it take the first 20 columns not rows can you help please
here is the file i need to take the 20 coulmns from
https://drive.google.com/file/d/1GWv7-jmZKwH-ssSWVHNgecHvmm29UeTQ/view?usp=sharing
Solution :-
Screenshot of the code...
Code in the text format (Kindly take care of indentation , refer screenshot if needed ... )
holder = 20
lines = 3
file = "123456.pssm"
_file = ".txt"
while 1:
out_file = input("[OUTPUT] - Please enter the name of file: ") +
_file
if (not _file):
print("Filename not specified - Please Try Again\n")
continue
break
with open(str(out_file), "w") as e:
with open(file, "r") as f:
for line in f:
k = line.strip().split()
if len(k) >= 20:
print(line.strip())
for i in range(holder):
e.write( k[i] + " ")
e.write("\n")
print("Information saved to {}".format(out_file))
Screenshot of the file written (first 20 columns ) using python code... (Run the code using python filename.py)
Consider python please for this problem: I did a python program to read the first 20 lines from a...
use python IDEL
Please highlight the answer
Problem 3 Files. Read the following code and answer the next five questions about it. The contents of the files list 1.txt and list2.txt are the following (given side by side): list 1. txt content: list2.txt content 2 apples 2 apples 3 oranges 1 loaf of bread 2 eggs 2 eggs 1 cereal box # the program code starts here filename1 = "list 1.txt" filename2 - "list2.txt" filename3 - "listdiff.txt" with open (filename1,"r")...
I cant get this python program to read all the unique words in a file. It can only read the number of the unique words in a line. import re import string from collections import Counter # opens user inputted filename ".txt" and (w+) makes new and writes def main(): textname = input("Enter the file to search: ") fh = open(textname, 'r', encoding='utf-8' ) linecount = 0 wordcount = 0 count = {} print("Sumary of the", fh) for line in...
I am having a little trouble with my Python3 code today, I am
not sure what I am doing wrong. Here are the instructions:
and here is my code:
update: I have seen I did not close x in sumFile and I am still
only getting a 2/10 on the grader. any help appreciated.
Lab-8 For today's lab you going to write six functions. Each function will perform reading and/or write to a file Note: In zybooks much like on...
I am working on Exercise 5.8 from Fundamentals of Python 2nd edition. Do you have a solution for this item? Thank you. Here is the code I have. I just need 1 instance of each to show in my output. should look like: AM 3 I 3 SAM 3 Thank you... # Put your code here #fileName = input("Enter the file name: ") fileName = "example.txt" #fileName = "kgtest.txt" inputFile = open(fileName, 'r') text = inputFile.read() #print(text) words = text.split()...
I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...
use python IDEL
Please highlight the answer
Problem 2 Files. Since almost all data can be stored in files, knowing how to use files in programs is invaluable. Today you will practice with opening a file for reading, writing and editing using the Python interpreter. Do not type messages in red into Python shell Question 14 0.5 pts create a new file mytext.txt for >>>f1 = open("mytest.txt","w+") writing & reading >>>f1.write("hello\n") >>>for i in range(5): f1.write(str(i) + "\n") >>>f1.readlines() record...
I'm a bit confused on how to get this program to run right. Here are the directions: Part 1: Write a Python function called reduceWhitespace that is given a string line and returns the line with all extra whitespace characters between the words removed. For example, ‘This line has extra space characters ‘ ‘This line has extra space characters’ Function name: reduceWhitespace Number of parameters: one string line Return value: one string line The main file should handle the...
I need python help .. I need to know if a user were to input 3 commands to a program and run it such as specify: Usage: ./filemaker INPUTCOMMANDFILE OUTPUTFILE RECORDCOUNT (./filemaker is the program)( (INPUTCOOMANDFUILE= a text file that contains key words that need to be searched through then decided what to do ) (RECORDCOUNT= number) Given an input file that contains the following: That specifies the text, then the output, and the number of times to be repeated...
I need help modifying this python code: a) I need to take 2 attributes of the data as int - (columns (3 & 5) of my data) b) I need to take 2 more attributes as floats -(columns 4&6 of my data) c) I need to take 1 attribute as string (column 16 of my data) How would I modify this code # # Initial version - "standard programming" # # Define a list for the data. The data structure...
Need help with the code for this assignment. Python Assignment: List and Tuples We will do some basic data analysis on information stored in external files. GirNames.txt contains a list of the 200 most popular names given to girls born in US from year 2000 thru 2009: (copy link and create a txt file): https://docs.google.com/document/d/11YCVqVTrzqQgp2xJqyqPruGtlyxs2X3DFWn1YUb3ddw/edit?usp=sharing BoyNames.txt contains a list of the 200 most popular names given to boys born in US from year 2000 thru 2009 (copy link and create...