Parsing data - Persian
- subtitles off
- captions off
- English
- Questions posted on Forums
- Python 3.4.3 Tutorials - Persian
-
IndexError: list index out of range
I have entered the following code in the editormath_marks_A = []for line in open("student_record.txt"): fields = line.split(";") region_code = fields[0] region_code_stripped = region_code.strip() math_mark_str = fields[5] math_mark = float(math_mark_str) if region_code == "A": math_marks_A.append(math_mark)but i am getting the following error after running the fileTraceback (most recent call last): File "/home/ranjeet/Desktop/python_plot/marks.py", line 6, in <module> math_mark_str = fields[5]IndexError: list index out of rangeplease help
12-13M 50-60S ranjeet71
Answer last updated on: July 22, 2024, 3:24 p.m.
-
Difference between %run <file name> and %run -i<file name>
When should we use %run -i<file name> command and when should we use %run <file name> command?
09-10M 50-60S stutisamanta04@gmail.com
Answer last updated on: July 25, 2023, 2:40 p.m.
-
%run marks.py command error in windows
In [27]: %run marks.py File "C:\Users\wci\marks.py", line 8 if region_code== "A"; ^SyntaxError: invalid syntax
09-10M 50-60S @its_Prachit
Answer last updated on: Sept. 9, 2021, 6:51 p.m.
-
error in %run command
after typing the last command %run marks.py , it shows an error as%run marks.py---------------------------------------------------------------------------NameError Traceback (most recent call last)~\marks.py in <module> 9 math_marks_A.append(math_mark) 10---> 11 math_marks_mean=sum(math_maths_A)/len(math_marks_A) 12 print(math_marks_mean)NameError: name 'math_maths_A' is not defined
10-11M 30-40S KAVYA_30
Answer last updated on: June 5, 2021, 7:52 p.m.
-
parsing data
In [29]: %run marks.pyIn [30]: %run marks.py---------------------------------------------------------------------------TypeError Traceback (most recent call last)~\marks.py in <module> 10 11---> 12 math_marks_mean = sum(math_marks_A) / len 13 (math_marks_A) 14 print (math_marks_mean)TypeError: unsupported operand type(s) for /: 'float' and 'builtin_function_or_method'
10-11M 30-40S Adarsh1211
Answer last updated on: Oct. 26, 2020, 9:53 a.m.
-
%run marks.py error
%run marks.pyit shows that math_marks_mean = sum(math_marks_A)/len(math_marks_A)then it shows that type error : unsupported operand type(s) for /: 'float' and 'builtin_function_or_method,
10-11M 30-40S aryamistry18@gnu.ac.in
Answer last updated on: Oct. 6, 2020, 11:01 a.m.
-
%run marks.py
I tried running the command after saving the marks.py in the working directory but it still shows%run mark.py File "C:\Users\HP\mark.py", line 2 for line in open("student_record.txt") ^SyntaxError: invalid syntax
09-10M 10-20S ASHABAREE
Answer last updated on: Sept. 7, 2020, 10:15 p.m.
-
split
can we merge/concatenate/combine two String?
04-05M 30-40S HITESH_NINAMA
Answer last updated on: June 5, 2020, 2:28 p.m.
-
Error in run command
Am not getting the mean value as per video. Its showing an error as %run -i "C:\Users\HP\Desktop\marks.py"ERROR:root:File `'C:\\Users\\HP\\Desktop\\marks.py'` not found.Can you please help me...
10-11M 30-40S sweacha.lakshmi@gmail.com
Answer last updated on: May 28, 2020, 12:37 a.m.
-
Not getting the final output
After typing the code and using the run command, I am not able to get the mean value.
10-11M 40-50S asad.ad1l
Answer last updated on: May 8, 2020, 9:31 p.m.
-
%run error
i am using windows 10,i place the command, %run desktop/marks.py got an error....In [31]: %run desktop/marks.py---------------------------------------------------------------------------TypeError Traceback (most recent call last)~\desktop\marks.py in <module> 8 if region_code=="A": 9 math_marks_A.append(math_mark)---> 10 math_marks_mean = sum(math_marks_A)/len 11 (math_marks_A) 12 print (math_marks_mean)TypeError: unsupported operand type(s) for /: 'float' and 'builtin_function_or_method'the code as below:math_marks_A=[]for line in open("desktop/student_record.txt"): fields=line.split(";") region_code=fields[0] region_code_stripped=region_code.strip() math_mark_str=fields[5] math_mark=float(math_mark_str) if region_code=="A": math_marks_A.append(math_mark)math_marks_mean = sum(math_marks_A)/len(math_marks_A)print (math_marks_mean)
10-11M 20-30S vineetsingh23
Answer last updated on: May 8, 2020, 2 p.m.
-
Self-assessment solution
1. Shouldn't the answer be line.split(';')?; instead of ,
11-12M 40-50S sakshithakur18@gmail.com
Answer last updated on: April 24, 2020, 10:21 a.m.
-
error %run
running file marks.py gives error on line 'math_marks_mean=sum(math_mark)/len'--> 'float' object is not iterable.code written in marks.py file is==>math_marks_A=[]for line in open("student_record.txt"): fields = line.split(";") region_code=fields[0] region_code_stripped=region_code.strip() math_mark_str=fields[5] math_mark=float(math_mark_str) if region_code=="A": math_marks_A.append(math_mark)math_marks_mean=sum(math_mark)/len(math_marks_A)Print(math_marks_mean)
10-11M 30-40S gourihalde@gmail.com
Answer last updated on: April 23, 2020, 10:49 a.m.
-
Difference between the commands
I have confusion between %run file and %run -i file. In both the cases, i am getting the output but i want to know which one to be used in which instance. what does -i indicates in the later command.
10-11M 30-40S madhavan.11601828@lpu.in
Answer last updated on: April 21, 2020, 10:24 p.m.
-
1Getting started with IPython
-
2Using plot command interactively
-
3Embellishing a plot
-
4Saving plots
-
5Multiple plots
-
6Subplots
-
7Additional features of IPython
-
8Loading Data From Files
-
9Plotting Data
-
10Other Types Of Plots
-
11Plotting Charts
-
12Getting started with Lists
-
13Getting started with for
-
14Getting started with strings
-
15Getting started with files
-
Parsing data
-
17Statistics
-
18Getting started with arrays
-
19Accessing parts of arrays
-
20Image manipulation using Arrays
-
21Basic Matrix Operations
-
22Advanced Matrix Operations
-
23Least square fit
-
24Basic datatypes and operators
-
25Sequence datatypes
-
26Input-output
-
27Conditional Statements
-
28Loops
-
29Manipulating lists
-
30Manipulating strings
-
31Getting started with tuples
-
32Dictionaries
-
33Sets in Python
-
34Getting Started with Functions
-
35Advanced Features of Functions
-
36Using Python Modules
-
37Writing Python Scripts
-
38Testing and Debugging
-
39Handling Errors and Exceptions
Questions posted on ST Forums:
223 visits
Outline:
پارسینگ دادهها چیست - تابع اسپلیت و ترکیب آن - توکنایزینگ چیست - چگونه رشته را با فواصل سفید جدا کنیم - تابع اسپلیت با آرگومان - تابع استریپ و مثال - تبدیل کردن رشته به عدد اعشاری و عدد صحیح - مثال برای خواندن یک فایل بزرگ دات تی اکس تی به صورت خط به خط و تجزیه هر رکورد - انجام محاسبات روی فایل دات تی اکس تی - اجرای فایل با استفاده از فرمان %رن -
Width: | 832 | Height: | 608 |
---|---|---|---|
Duration: | 00:12:33 | Size: | 4.5 MB |
Show video info