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. [Codeforces 1037E] Trip

    [题目链接] http://codeforces.com/problemset/problem/1037/E [算法] 首先离线 , 将问题倒过来考虑 , 转化为 : 每次删除一条边 , 此时最多有多 ...

  2. 【前端】jQuery的animate在火狐浏览器上不支持backgroundPosition的解决方法

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/4375678.html jQuery的animate是一个非常好用的东东,但某些动画效果支持得不够好,比如back ...

  3. Java IO 字节流与字符流 (二)

    1. 什么是流 Java中的流是对字节序列的抽象,我们可以想象有一个水管,只不过现在流动在水管中的不再是水,而是字节序列.和水流一样,Java中的流也具有一个“流动的方向”,通常可以从中读入一个字节序 ...

  4. 数据读进set,进行后处理

    #include <iostream> #include <vector> #include <cstddef> #include <string> # ...

  5. 使用Google Closure Compiler全力压缩代码(转)

    JavaScript压缩代码的重要性不言而喻,如今的压缩工具也有不少,例如YUI Compressor,Google Closure Compiler,以及现在比较红火的UglifyJS.Uglify ...

  6. TI BLE: Advertisement

    #define GAPROLE_ADVERT_ENABLED 0x305 //!< Enable/Disable Advertising. Read/Write. Size is uint8. ...

  7. 如何快速删除Linux下的svn隐藏文件及其他临时文件 (转载)

    转自:http://blog.csdn.net/edsam49/article/details/5840489 在Linux下,你的代码工程如果是用svn进行管理的,要删除Linux kernel里的 ...

  8. 3-5 编程练习:jQuery实现简单的图片对应展示效果

    3-5 编程练习:jQuery实现简单的图片对应展示效果 通过这个章节的学习, 老师带领大家完成了一个基本的图片切换特效,接下来,我们也实现一个类似的效果,点击相应的按钮,切换对应的图片. 效果图 : ...

  9. Linux学习之01_基础命令介绍

    初学Linux,还在摸索中,在这个过程中希望能记录下学习到的东西,参考的的书籍为<鸟哥的Linux私房菜> 在这里学到的主要命令有这几个: data cal bc man shutdown ...

  10. jQuery setInterval倒计时精确到毫秒

    效果类似于:购物抢购倒计时-->在跳转N多个页面之后,倒计时间仍然正常显示. 思路: 结束时间是固定不变的(endTime),一直在改变的是当下的时间(curTime = new date()) ...