I need to convert a GraphML file into a DOT format, but I am not familiar on how to perform the conversion.
#you should use export_graphviz
from sklearn.tree import export_graphviz
#to get dot data
dot_data = export_graphviz(clasifier_name,out_file=None)
Related
I am import two different proto files in my current proto file as below
import "author/message/name.proto"
import "reader/message/details.proto"
in name.proto I have go_package = "author/message" and in details.proto I have go_package = "reader/message" because of which when pb.go is generated import alias is showing as below
message1 "author/message"
message2 "reader/message"
I am trying to find a way where i can name alias like authormsg and readermsg respectively during pb.go generation. I have checked documentation but couldnt find anyway to do that.
You can add the explicit Go package name like this:
name.proto: option go_package="author/message;authormsg"
details.proto: option go_package="reader/message;readermsg"
Means you add the package name separated with a semicolon (;) after the import path.
Note:
This usage is discouraged since the package name will be derived by default from the import path in a reasonable manner.
Protocol Buffers documentation
What is a .rl0 file format and how to access its data?
I have been searching for RL0 file format but what I get is r10 and rlo file format and I am unable to get the data inside the file.
How to get the data inside the file?
It is in hex format you can use the following code.
import binascii
with open (final_name, "rb") as myfile:
header=myfile.read()
header = str(binascii.hexlify(header))[2:-1]
print(header)
So I am trying to move say all files starting with "A" to a certain directory. Now I now Windows command prompt does not support this method:
move A* A_Dir
But could this combined with Python find a way? Or am I gonna have to go through each individual file?
Such as:
contents=os.listdir('.')
for file in content:
if file[0] == 'A':
os.system("move %s A_Dir" % file)
... etc. Is there any other solution that is more simpler and quicker?
-Thanks!
On Windows: This example moves files starting with "A" from "C:\11" to "C:\2"
Option #1: if you are using batch file, create batch file (movefiles.bat) as show below:
movefiles.bat:
move /-y "C:\11\A*.txt" "C:\2\"
Execute this batch file from python script as shown below:
import os
batchfile = "C:\\1\\movefiles.bat"
os.system( "%s" % batchfile)
Option #2: using glob & shutil
import glob
import shutil
for data in glob.glob("C:\\11\\A*.txt"):
shutil.move(data,"C:\\2\\")
If we want to move all files and directory starting with A:
import glob
import shutil
for data in glob.glob("C:\\11\\A*"):
shutil.move(data,"C:\\2\\")
Based on #eryksun comment, I have added if not os.path.isdir(data):, if only files starting with A are required to be moved and in this case, directory will be ignored.
import glob
import shutil
import os
for data in glob.glob("C:\\11\\A*"):
if not os.path.isdir(data):
shutil.move(data,"C:\\2\\")
Without having to use Image::Magick;, is there a way to output to the local file system an MSSQL Image string as a JPEG/PNG file.
The following in C# works very well, struggling to find the equivalent in Perl.
string base64string = "/9j/4AAQSkZJRgABAQAAAQABAAD/4QB..."; # This string shortened otherwise it would not fit
byte[] blob = Convert.FromBase64String(base64string);
File.WriteAllBytes(#"C:\image.jpg", blob);
Thanks.
Looks like you just need decode_base64 on your string. Then write it to the file opened with > and run binmode on handler. So your data will not be corrupted by new line character conversion.
I have to import in python the containt of a French written xls file.. I was managing to use the xlrd library but I'm not able to deal with the accent. I know the right codec should be UTF-8, but I don't know how to set it in the starting xls file..
any hint?
SOLVED:
in the end I decided to export the original file in csv, using the codec utf-8.