Goal:

I want to write a program for this:
In a folder I have =n= number of files;
first read one file and perform some operation then store result in a separate file.
Then read 2nd file, perform operation again and save result in new 2nd file.
Do the same procedure for n number of files.
The program reads all files one by one and
stores results of each file separately.

solution:

#+BEGIN_SRC Python
import sys
#argv is your commandline arguments, argv[0] is your program name, so skip it

for n in sys.argv[1:]:
print(n) #print out the filename we are currently processing
input=open(n,"r")
output=open(n,+".out","w")
# do some processing
input.close()
output.close()
#+END_SRC

- syn :: system-specific parameters and functions
- module :: a file contains Python code

why python module?

Python module is used to group related functions, classes, and variables
for better code management and avoiding name clash

https://stackoverflow.com/questions/208120/how-to-read-and-write-multiple-files

How to read and write multiple files in Python?的更多相关文章

  1. 基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?

    复现过程 首先,我创建了一个基于Picture Library的图片文档库,名字是 Pic Lib 创建完毕后,我点击它的Upload 下拉菜单,点击Upload Picture按钮 在弹出的对话框中 ...

  2. How to effectively work with multiple files in Vim?

    Why not use tabs (introduced in Vim 7)? You can switch between tabs with :tabn and :tabp, With :tabe ...

  3. How to Upload multiple files to documentLibrary in one time

         In a Sharepoint 2013 website,we can upload one file to the documentlibrary by click "Uploa ...

  4. Uploading multiple files asynchronously by blueimp jquery-fileupload

    Uploading multiple files asynchronously by blueimp jquery-fileupload   Solved. Fiddle: http://jsfidd ...

  5. How to attach multiple files in the Send Mail Task in SSIS

    Let’s say you need to create a SSIS package that creates 2 files and emails the files to someone. Yo ...

  6. Huge CSV and XML Files in Python, Error: field larger than field limit (131072)

    Huge CSV and XML Files in Python January 22, 2009. Filed under python twitter facebook pinterest lin ...

  7. Working with Excel Files in Python

    Working with Excel Files in Python from: http://www.python-excel.org/ This site contains pointers to ...

  8. [SCSS] Organize SCSS into Multiple Files with Partials

    Tired of dealing with monolithic CSS files? Are requests for multiple CSS files hurting your perform ...

  9. Retrofit Upload multiple files and parameters

    Retrofit 的介绍以及基本使用 这里不再说明. 关于多文件上传 以及上传文件的同时携带多个参数说明 网上涉及到的不是太多. 上一张帅图: 代码: apiService: /** params 参 ...

随机推荐

  1. P2465 [SDOI2008]山贼集团 dp

    这个题是一道树形dp+状压dp二合一,先预处理每种组合会有什么额外的费用,然后在树上dp就行了. 题干: 题目描述 某山贼集团在绿荫村拥有强大的势力,整个绿荫村由N个连通的小村落组成,并且保证对于每两 ...

  2. SQLALchemy之介绍,基本使用

    一.介绍 SQLALchemy也是一个python的ORM框架,django内部的ORM框架只适用于django,而SQLALchemy适用于所有python的web框架 SQLAlchemy是一个基 ...

  3. 不温不火WindowsPhone

    最近在考虑是否转其他平台,如iOS或者Android或者javascript等. 已经以Windows Phone 开发作为工作就一年了(也不算是真正的Windows Phone开发吧,仅仅是开发高德 ...

  4. C# 树次结构的数据

    public static void CreateTree(TreeView tv) { ///获取层次结构的数据 Tree tree = new Tree(); DataSet ds = tree. ...

  5. php使用邮箱发送验证码

    如果看着文字眼乏就去看看视频吧-> 如何注册腾讯企业邮箱 https://www.bilibili.com/video/av14351397/ 如何在项目中使用 https://www.bili ...

  6. JavaScript--DOM节点属性

    节点属性 在文档对象模型 (DOM) 中,每个节点都是一个对象.DOM 节点有三个重要的属性 : 1. nodeName : 节点的名称 2. nodeValue :节点的值 3. nodeType ...

  7. hdu5926Mr. Frog’s Game

    Mr. Frog's Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  8. Android 性能优化(12)网络优化( 8)Monitoring the Battery Level and Charging State

    Monitoring the Battery Level and Charging State PreviousNext This lesson teaches you to Determine th ...

  9. EasyUI系列学习(九)-Panel(面板)

    一.加载方式 1.class加载 <div class="easyui-panel" title="面板一" style="width:500p ...

  10. DecorView 的创建

    在Activity 的启动过程中,调用ActivityThread 的handleResumeActivity 方法时,先得到一个与Activity 关联的PhoneWindow 对象,然后通过Pho ...