title: Python: how to convert pickled txt files into gpickles for networkx?
body: <p>After working with a number of different occurrences of the same graph <code>G</code>, I dumped them as <code>txt</code> files with <code>pickle</code> using this line:</p>
  
  <pre><code>pickling=pickle.dump(G,open('pickled_G.txt','w')) #Example for one single graph
  </code></pre>
  
  <p>Now, for purposes of further calculations, I want to load these graphs back into networkx by doing:</p>
  
  <pre><code>work_dir=raw_input('Working directory: ')
  for i,file in enumerate(os.listdir(work_dir)):
      if file.endswith(".txt"):
         filename=os.path.abspath(file)
         F = nx.read_gpickle(filename) #Loading graph G back into Python and calling it F
  </code></pre>
  
  <p><strong>EDIT</strong>
  I get this error: <code>ImportError: No module named copy_reg</code>, which points at the line where <code>F=nx.read_gpickle(filename)</code>.</p>
  
  <p>I assume the problem is that I have a bunch of <code>txt</code> files and I am trying to load them as if they were <code>gpickle</code>. If my take is correct, how could I convert my <code>.txt</code> files into <code>.gpickle</code> <strong>without altering the graph features</strong>? This would spare me re-running my simulations.</p>