# Close file to delete

**URL:** <https://forum.inductiveautomation.com/t/close-file-to-delete/3915>\
**Category:** Ignition\
**Created:** [January 26, 2012, 1:55am UTC](https://forum.inductiveautomation.com/t/close-file-to-delete/3915 "2012-01-26T01:55:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfyanez](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@dfyanez](https://forum.inductiveautomation.com/u/dfyanez)\
**Post date:** [January 26, 2012, 1:55am UTC](https://forum.inductiveautomation.com/t/close-file-to-delete/3915/1 "2012-01-26T01:55:23Z")

</div>

Hello guys, i have managed to take some values from a text file and import them to a DB  
now i need to close the file and delete it, it would be ok if just close it.  
that way can overwrite the same file,  
what Im getting is that the file is been use by java, i have tried to file.close but it says list object has no attribute close

Have a clue of what can i do?

Thanks

`
adir = 'C:\\Control\\'
rFile = open(adir + 'kappa240.txt', 'r').readlines()
job = rFile[0].replace("job=", "")
product = rFile[1].replace("circuit=", "")
quantity = rFile[2].replace("quantity=", "")
print job, product, quantity
system.db.runUpdateQuery("INSERT INTO wokappa240 (job, circuit, qty) values (%s,%s,%s)" %(job, product, quantity))
rFile.close()
import os
os.remove("rFile")`

---

<div class="post-metadata">

**Author:** ![dfyanez](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@dfyanez](https://forum.inductiveautomation.com/u/dfyanez)\
**Post date:** [January 27, 2012, 3:48am UTC](https://forum.inductiveautomation.com/t/close-file-to-delete/3915/2 "2012-01-27T03:48:51Z")

</div>

I just figured out heres the code I used to read a text file insert values from text file to database and delete the file, hope it would be helpful for somebody

```auto
fo = open(r'c:\\folder\\file.txt')
lines = fo.readlines()
fo.close()
job = lines[0].replace("job=", "")
product = lines[1].replace("circuit=", "")
quantity = lines[2].replace("quantity=", "")
print job, product, quantity
system.db.runUpdateQuery("INSERT INTO csv (job, circuit, qty) values (%s,%s,%s)" %(job, product, quantity))
import os
os.remove('c:\\folder\\file.txt')
```
