How to use Google Colab to work with local files?











up vote
0
down vote

favorite












I have a Jupiter notebook and I have written codes to work with data. Now I want to use Colab for it's GPU computation power, so I need to read from and write to local files in my computer from Colab. I don't want to select file manually using:



from google.colab import files
uploaded = files.upload()


mentioned in this link where a "select file" pop up will appear, I want this action to be automatically. Let me clarify that:

I have code below where I read data from a local file:



# Reading the csv file and convert it to a dataframe using pandas library
train_set = pd.read_csv('Datasets/train.csv')


Then I per-process data and output the result in another file. To do that, I need to open a file, read the content of it which is the version of my created output file, and then save the output file:



output_version = open('OutputVersion','r+')
version = output_version.read()

training_set.to_csv('Datasets/training_set_processed_{}.csv'.format(version))


So, I have to read, manipulate and write files in my local storage from Colab automatically. How can I do that? I have read this manual but I couldn't get that. Again, I don't want a 'select file' dialogue pop-up.



Thanks in Advance










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a Jupiter notebook and I have written codes to work with data. Now I want to use Colab for it's GPU computation power, so I need to read from and write to local files in my computer from Colab. I don't want to select file manually using:



    from google.colab import files
    uploaded = files.upload()


    mentioned in this link where a "select file" pop up will appear, I want this action to be automatically. Let me clarify that:

    I have code below where I read data from a local file:



    # Reading the csv file and convert it to a dataframe using pandas library
    train_set = pd.read_csv('Datasets/train.csv')


    Then I per-process data and output the result in another file. To do that, I need to open a file, read the content of it which is the version of my created output file, and then save the output file:



    output_version = open('OutputVersion','r+')
    version = output_version.read()

    training_set.to_csv('Datasets/training_set_processed_{}.csv'.format(version))


    So, I have to read, manipulate and write files in my local storage from Colab automatically. How can I do that? I have read this manual but I couldn't get that. Again, I don't want a 'select file' dialogue pop-up.



    Thanks in Advance










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a Jupiter notebook and I have written codes to work with data. Now I want to use Colab for it's GPU computation power, so I need to read from and write to local files in my computer from Colab. I don't want to select file manually using:



      from google.colab import files
      uploaded = files.upload()


      mentioned in this link where a "select file" pop up will appear, I want this action to be automatically. Let me clarify that:

      I have code below where I read data from a local file:



      # Reading the csv file and convert it to a dataframe using pandas library
      train_set = pd.read_csv('Datasets/train.csv')


      Then I per-process data and output the result in another file. To do that, I need to open a file, read the content of it which is the version of my created output file, and then save the output file:



      output_version = open('OutputVersion','r+')
      version = output_version.read()

      training_set.to_csv('Datasets/training_set_processed_{}.csv'.format(version))


      So, I have to read, manipulate and write files in my local storage from Colab automatically. How can I do that? I have read this manual but I couldn't get that. Again, I don't want a 'select file' dialogue pop-up.



      Thanks in Advance










      share|improve this question













      I have a Jupiter notebook and I have written codes to work with data. Now I want to use Colab for it's GPU computation power, so I need to read from and write to local files in my computer from Colab. I don't want to select file manually using:



      from google.colab import files
      uploaded = files.upload()


      mentioned in this link where a "select file" pop up will appear, I want this action to be automatically. Let me clarify that:

      I have code below where I read data from a local file:



      # Reading the csv file and convert it to a dataframe using pandas library
      train_set = pd.read_csv('Datasets/train.csv')


      Then I per-process data and output the result in another file. To do that, I need to open a file, read the content of it which is the version of my created output file, and then save the output file:



      output_version = open('OutputVersion','r+')
      version = output_version.read()

      training_set.to_csv('Datasets/training_set_processed_{}.csv'.format(version))


      So, I have to read, manipulate and write files in my local storage from Colab automatically. How can I do that? I have read this manual but I couldn't get that. Again, I don't want a 'select file' dialogue pop-up.



      Thanks in Advance







      python-3.x local-storage jupyter-notebook google-colaboratory






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 21:52









      Ali Majed HA

      1013




      1013
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You might want to use the file browser in the left hand side in order to upload files.



          enter image description here



          enter image description here



          If you have a lot of files, a simpler method still is to mount your Google Drive in the filesystem.






          share|improve this answer





















          • As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
            – Ali Majed HA
            Nov 8 at 6:09











          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%2f53198405%2fhow-to-use-google-colab-to-work-with-local-files%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You might want to use the file browser in the left hand side in order to upload files.



          enter image description here



          enter image description here



          If you have a lot of files, a simpler method still is to mount your Google Drive in the filesystem.






          share|improve this answer





















          • As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
            – Ali Majed HA
            Nov 8 at 6:09















          up vote
          0
          down vote













          You might want to use the file browser in the left hand side in order to upload files.



          enter image description here



          enter image description here



          If you have a lot of files, a simpler method still is to mount your Google Drive in the filesystem.






          share|improve this answer





















          • As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
            – Ali Majed HA
            Nov 8 at 6:09













          up vote
          0
          down vote










          up vote
          0
          down vote









          You might want to use the file browser in the left hand side in order to upload files.



          enter image description here



          enter image description here



          If you have a lot of files, a simpler method still is to mount your Google Drive in the filesystem.






          share|improve this answer












          You might want to use the file browser in the left hand side in order to upload files.



          enter image description here



          enter image description here



          If you have a lot of files, a simpler method still is to mount your Google Drive in the filesystem.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 7 at 22:01









          Bob Smith

          5,2791625




          5,2791625












          • As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
            – Ali Majed HA
            Nov 8 at 6:09


















          • As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
            – Ali Majed HA
            Nov 8 at 6:09
















          As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
          – Ali Majed HA
          Nov 8 at 6:09




          As I have mentioned in the question, I don't want this action to be manually and using a dialogue box. Files are changing as data is preprocessed in a different way and I want the Colab to read and write file automatically.
          – Ali Majed HA
          Nov 8 at 6:09


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53198405%2fhow-to-use-google-colab-to-work-with-local-files%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







          這個網誌中的熱門文章

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Xamarin.form Move up view when keyboard appear

          JBPM : POST request for execute process go wrong