473,387 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to let code find the file size and how to let user input segment size

Expand|Select|Wrap|Line Numbers
  1. f = open("centaur_1.mpg","rb")
  2. #create a for loop and split file into 20 parts
  3. buffer=f.read()  # readinto a large buffer to check its size
  4. #f.close() #close the file
  5. filesize=len(buffer)
  6. print filesize
  7. splitsize=int(filesize/segmentsize)
  8. f.seek(0)  # reset to beginning of file
  9. #smallfbuf=[]
  10. for i in range(splitsize+1):
  11.     filename="part"+str(i)+".mpg"
  12.     f2= open(filename,"wb")
  13.     buffer2 = f.read(splitsize)
  14.     f2.write(buffer2)
  15.     f2.close()
  16. f.close()

from the above codes, how do i get the filesize and the user to input segmentsize
Jul 3 '14 #1
1 1541
sicarie
4,677 Expert Mod 4TB
It looks like you can import os and then use the getsize() function to see the filesize:

Expand|Select|Wrap|Line Numbers
  1. import os
  2. size = os.path.getsize('centaur_1.mpg')
  3. print size
  4.  
So I got that from Googling "python get file size" and I would Google "python get user input" to allow the user to input the segment size.

Good luck!
Jul 23 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Liam Gibbs | last post by:
Does anyone know how to make input fields smaller, using a smaller font? I want to know how to make my textboxes and such like the ones at http://www.gracenote.com/music/ , but reading teh code...
2
by: Matthew Louden | last post by:
In ASP, if I have asppage.asp for GUI and aspprocess.asp for process requests from database. In asppage.asp code will be like: <form action="aspprocess.asp" method="POST"> GUI CODE </form> ...
3
by: dei3cmix | last post by:
Hey, I am having a problem with a program I am working on. Basically, the first part of the program gets input from a file using cin.getline. Then the second part, (still in the same main as the...
4
by: google.com | last post by:
Hi there! I've been digging around looking for a sample on how to upload a file without user action. I found the following article covering the area: ...
14
by: n3o | last post by:
Hello Comp.Lang.C Members, I have an issue with user input that I have been trying to figure out for the longest. For instance, let's say you have something like this: void foo() { int num;...
2
by: ch68813 | last post by:
I'm making a program that asks for an item number and if it matches an item number in the text file it will then determine its next move by what variable is displayed on the line that the item number...
4
by: myself2211 | last post by:
Hi, this is my first attempt at Python, what I am trying to achieve is a script that will ask the user for input, search a txt file and display the output or give not found message. Ideally I would...
1
by: golnaz hgh | last post by:
the xml file is like this: <publist> <book> A book entry has the following fields: o Title; o One or more authors; o Publisher; o Year </book>
1
by: markzabo | last post by:
Hi, I am currently working on a project that i was asked to do for my boss. What does the project consist of... First of all I need to select some pictures from a disk/drive, they will then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.