Message Boards Message Boards

0
|
6003 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Avoid error while importing from the same directory?

Posted 5 years ago

Good morning/afternoon.

I have a problem. I want to import two .txt files from the same directory in which the program that I am writing is located. However, only one of them is found, apc300000tf500uncertainties4ft.txt, while apc300000tf500uncertainties4smolyak1.txt is not. I am attaching a screenshot of the situation in case someone can help me.

Any coment is appreciated.

Regards. Jaime.folder in which the code and files are located

POSTED BY: Jaime de la Mota
4 Replies
Posted 5 years ago

1) are we sure these files have the .txt extension?

2) You have a trailing open parenthesis ('('), which is causing a syntax error in the cell you're trying to evaluate.

POSTED BY: Kyle Martin

Yes, i am sure it is a txt file, see first attacehed image, even though it is in spanish you can see that the extension is txt. enter image description here

About the parenthesis, you are right, it is out of place. However it is not the source of the error. My code still does not recognize the second table.

POSTED BY: Jaime de la Mota
Posted 5 years ago

Can you upload a .zip file of this entire directory so others can see exactly what you're working with?

POSTED BY: Kyle Martin

Are both files returned by:

FileNames["*.txt", Directory[]]

And if so, does:

file=Part[FileNames["*.txt", Directory[]],1];
Import[file]

and so on for each position (presumably there will be two based on your screenshot) work?

Btw, using file names like "a.txt" or "b.txt" would be kinder for demonstration purposes here.

POSTED BY: Josh Lietz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract