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...
![1 holder 20 lines = 3 3 file 123456.pssm 4 _file .txt 6 while 1: out-file input ( [OUTPUT] -Please enter the name of file](http://img.homeworklib.com/images/42d1df40-efdb-47dc-be23-f09d045eab74.png?x-oss-process=image/resize,w_560)
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...
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")...
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")...
PYTHON PROGRAMMING: I have this program right now where it allows users to choose from a category(pulling from the file). Then it will print the University or people from that text file. What I want to do next on my code is for users to search for a specific string from that file and it will display both the University and People that have that matching string. It can be the whole word or part of the string from that...
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 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 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...
Hi. It's a python and I got an error below comment import numpy as np arr=np.genfromtxt("/Volumes/Samsung SSD 860 EVO 500GB Media/Download/primenumbers.txt", dtype=int) arr=arr.reshape(-1,1) arr.shape def find_cat(x): if x<= 300: return '<=300' elif x <= 600: return '<=600' else: return '<=1000' arr2 = np.apply_along_axis(find_cat, axis=1, arr=arr) arr2 = arr2.reshape(-1,1) arr3 = np.hstack((arr, arr2)) arr_300 = np.array((col[0] for col in arr3 if col[i]=='<=300'), dtype=int) arr_300 arr_300.shape count_300=len(arr_300) count_300 avg_300=round(np.mean(arr_300, 2) avg_300 print("Number of items in category \ "<=300\"= (one), and average of...
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...