Getting special characters when I try to list out all filenames











up vote
0
down vote

favorite












I am using Google Colab and I fairly new to it, so please pardon my ignorance. I am trying to get the file names of all the frames in a certain folder.



filenames_pics = !ls {PATH}/Pictures


I do this to try to copy all the filenames.



The output I get when i try to print it is



['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']


What is interesting is that all the first values have this 't' in it with three frame names in it, and this is just driving me mad.



All my file names are in oder



Please help!










share|improve this question




















  • 2




    replace 't' with space ' ' and split on space ' ' ?
    – mad_
    Nov 7 at 18:26

















up vote
0
down vote

favorite












I am using Google Colab and I fairly new to it, so please pardon my ignorance. I am trying to get the file names of all the frames in a certain folder.



filenames_pics = !ls {PATH}/Pictures


I do this to try to copy all the filenames.



The output I get when i try to print it is



['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']


What is interesting is that all the first values have this 't' in it with three frame names in it, and this is just driving me mad.



All my file names are in oder



Please help!










share|improve this question




















  • 2




    replace 't' with space ' ' and split on space ' ' ?
    – mad_
    Nov 7 at 18:26















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am using Google Colab and I fairly new to it, so please pardon my ignorance. I am trying to get the file names of all the frames in a certain folder.



filenames_pics = !ls {PATH}/Pictures


I do this to try to copy all the filenames.



The output I get when i try to print it is



['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']


What is interesting is that all the first values have this 't' in it with three frame names in it, and this is just driving me mad.



All my file names are in oder



Please help!










share|improve this question















I am using Google Colab and I fairly new to it, so please pardon my ignorance. I am trying to get the file names of all the frames in a certain folder.



filenames_pics = !ls {PATH}/Pictures


I do this to try to copy all the filenames.



The output I get when i try to print it is



['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']


What is interesting is that all the first values have this 't' in it with three frame names in it, and this is just driving me mad.



All my file names are in oder



Please help!







python google-colaboratory






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 22:36









Miki

29.1k851131




29.1k851131










asked Nov 7 at 18:24









Bhaskar Ghosh

55




55








  • 2




    replace 't' with space ' ' and split on space ' ' ?
    – mad_
    Nov 7 at 18:26
















  • 2




    replace 't' with space ' ' and split on space ' ' ?
    – mad_
    Nov 7 at 18:26










2




2




replace 't' with space ' ' and split on space ' ' ?
– mad_
Nov 7 at 18:26






replace 't' with space ' ' and split on space ' ' ?
– mad_
Nov 7 at 18:26














2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










It's probably simpler to use the built-in Python os.listdir function.



Here's a full example:



https://colab.research.google.com/drive/1EKhDSUHBfzGdRPxm9gBGPfDGQ2vX5cPe



The key snippet:



# Python code to list the directory.
import os
pictures = os.listdir('Pictures/')
for fname in pictures:
print (fname)
print ('full path', os.path.join(os.getcwd(), fname))





share|improve this answer





















  • Hello! thank you so much. This worked like a charm to get the filenames! :)
    – Bhaskar Ghosh
    Nov 7 at 19:21












  • The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 19:23


















up vote
0
down vote













You can just replace 't with space to match the pattern



lst=['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']

l=
import re
for i in lst:
l.append(re.sub('s{2,}|t',' ',i))
print(l)


Output:



['frame1000.png frame15320.png frame436.png frame572.png frame680.png',
'frame1004.png frame15324.png frame440.png frame576.png frame684.png',
'frame1008.png frame1588.png frame508.png frame580.png frame688.png',
'frame100.png frame1592.png frame512.png frame584.png frame692.png',
'frame1012.png frame16432.png frame516.png frame588.png frame696.png']





share|improve this answer























  • Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 18:51












  • @BhaskarGhosh Edited
    – mad_
    Nov 7 at 18:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195557%2fgetting-special-characters-when-i-try-to-list-out-all-filenames%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










It's probably simpler to use the built-in Python os.listdir function.



Here's a full example:



https://colab.research.google.com/drive/1EKhDSUHBfzGdRPxm9gBGPfDGQ2vX5cPe



The key snippet:



# Python code to list the directory.
import os
pictures = os.listdir('Pictures/')
for fname in pictures:
print (fname)
print ('full path', os.path.join(os.getcwd(), fname))





share|improve this answer





















  • Hello! thank you so much. This worked like a charm to get the filenames! :)
    – Bhaskar Ghosh
    Nov 7 at 19:21












  • The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 19:23















up vote
0
down vote



accepted










It's probably simpler to use the built-in Python os.listdir function.



Here's a full example:



https://colab.research.google.com/drive/1EKhDSUHBfzGdRPxm9gBGPfDGQ2vX5cPe



The key snippet:



# Python code to list the directory.
import os
pictures = os.listdir('Pictures/')
for fname in pictures:
print (fname)
print ('full path', os.path.join(os.getcwd(), fname))





share|improve this answer





















  • Hello! thank you so much. This worked like a charm to get the filenames! :)
    – Bhaskar Ghosh
    Nov 7 at 19:21












  • The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 19:23













up vote
0
down vote



accepted







up vote
0
down vote



accepted






It's probably simpler to use the built-in Python os.listdir function.



Here's a full example:



https://colab.research.google.com/drive/1EKhDSUHBfzGdRPxm9gBGPfDGQ2vX5cPe



The key snippet:



# Python code to list the directory.
import os
pictures = os.listdir('Pictures/')
for fname in pictures:
print (fname)
print ('full path', os.path.join(os.getcwd(), fname))





share|improve this answer












It's probably simpler to use the built-in Python os.listdir function.



Here's a full example:



https://colab.research.google.com/drive/1EKhDSUHBfzGdRPxm9gBGPfDGQ2vX5cPe



The key snippet:



# Python code to list the directory.
import os
pictures = os.listdir('Pictures/')
for fname in pictures:
print (fname)
print ('full path', os.path.join(os.getcwd(), fname))






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 7 at 18:31









Bob Smith

5,2191625




5,2191625












  • Hello! thank you so much. This worked like a charm to get the filenames! :)
    – Bhaskar Ghosh
    Nov 7 at 19:21












  • The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 19:23


















  • Hello! thank you so much. This worked like a charm to get the filenames! :)
    – Bhaskar Ghosh
    Nov 7 at 19:21












  • The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 19:23
















Hello! thank you so much. This worked like a charm to get the filenames! :)
– Bhaskar Ghosh
Nov 7 at 19:21






Hello! thank you so much. This worked like a charm to get the filenames! :)
– Bhaskar Ghosh
Nov 7 at 19:21














The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
– Bhaskar Ghosh
Nov 7 at 19:23




The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
– Bhaskar Ghosh
Nov 7 at 19:23












up vote
0
down vote













You can just replace 't with space to match the pattern



lst=['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']

l=
import re
for i in lst:
l.append(re.sub('s{2,}|t',' ',i))
print(l)


Output:



['frame1000.png frame15320.png frame436.png frame572.png frame680.png',
'frame1004.png frame15324.png frame440.png frame576.png frame684.png',
'frame1008.png frame1588.png frame508.png frame580.png frame688.png',
'frame100.png frame1592.png frame512.png frame584.png frame692.png',
'frame1012.png frame16432.png frame516.png frame588.png frame696.png']





share|improve this answer























  • Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 18:51












  • @BhaskarGhosh Edited
    – mad_
    Nov 7 at 18:56















up vote
0
down vote













You can just replace 't with space to match the pattern



lst=['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']

l=
import re
for i in lst:
l.append(re.sub('s{2,}|t',' ',i))
print(l)


Output:



['frame1000.png frame15320.png frame436.png frame572.png frame680.png',
'frame1004.png frame15324.png frame440.png frame576.png frame684.png',
'frame1008.png frame1588.png frame508.png frame580.png frame688.png',
'frame100.png frame1592.png frame512.png frame584.png frame692.png',
'frame1012.png frame16432.png frame516.png frame588.png frame696.png']





share|improve this answer























  • Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 18:51












  • @BhaskarGhosh Edited
    – mad_
    Nov 7 at 18:56













up vote
0
down vote










up vote
0
down vote









You can just replace 't with space to match the pattern



lst=['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']

l=
import re
for i in lst:
l.append(re.sub('s{2,}|t',' ',i))
print(l)


Output:



['frame1000.png frame15320.png frame436.png frame572.png frame680.png',
'frame1004.png frame15324.png frame440.png frame576.png frame684.png',
'frame1008.png frame1588.png frame508.png frame580.png frame688.png',
'frame100.png frame1592.png frame512.png frame584.png frame692.png',
'frame1012.png frame16432.png frame516.png frame588.png frame696.png']





share|improve this answer














You can just replace 't with space to match the pattern



lst=['frame1000.pngtframe15320.pngtframe436.png  frame572.png  frame680.png',
'frame1004.pngtframe15324.pngtframe440.png frame576.png frame684.png',
'frame1008.pngtframe1588.pngtframe508.png frame580.png frame688.png',
'frame100.pngtframe1592.pngtframe512.png frame584.png frame692.png',
'frame1012.pngtframe16432.pngtframe516.png frame588.png frame696.png']

l=
import re
for i in lst:
l.append(re.sub('s{2,}|t',' ',i))
print(l)


Output:



['frame1000.png frame15320.png frame436.png frame572.png frame680.png',
'frame1004.png frame15324.png frame440.png frame576.png frame684.png',
'frame1008.png frame1588.png frame508.png frame580.png frame688.png',
'frame100.png frame1592.png frame512.png frame584.png frame692.png',
'frame1012.png frame16432.png frame516.png frame588.png frame696.png']






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 7 at 18:56

























answered Nov 7 at 18:30









mad_

3,1111920




3,1111920












  • Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 18:51












  • @BhaskarGhosh Edited
    – mad_
    Nov 7 at 18:56


















  • Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
    – Bhaskar Ghosh
    Nov 7 at 18:51












  • @BhaskarGhosh Edited
    – mad_
    Nov 7 at 18:56
















Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
– Bhaskar Ghosh
Nov 7 at 18:51






Hello! Thank you so much for the quick response. The output that i was trying to get was ['frame1000.png frame15320.png frame436.png frame572.png frame680.png', 'frame1004.png frame15324.png frame440.png frame576.png frame684.png', 'frame1008.png frame1588.png frame508.png frame580.png frame688.png', 'frame100.png frame1592.png frame512.png frame584.png frame692.png', 'frame1012.png frame16432.png frame516.png frame588.png frame696.png']
– Bhaskar Ghosh
Nov 7 at 18:51














@BhaskarGhosh Edited
– mad_
Nov 7 at 18:56




@BhaskarGhosh Edited
– mad_
Nov 7 at 18:56


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53195557%2fgetting-special-characters-when-i-try-to-list-out-all-filenames%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()