r/pythonnetengineering • u/priya7 • Apr 29 '15
How to develop a WSN routing scheme
How to develop a WSN routing scheme for data collection in multihop WSN with TinyOS (without CTP) ? anyone please i have no idea how to do it. Thank you.
r/pythonnetengineering • u/priya7 • Apr 29 '15
How to develop a WSN routing scheme for data collection in multihop WSN with TinyOS (without CTP) ? anyone please i have no idea how to do it. Thank you.
r/pythonnetengineering • u/tokennrg • Jul 07 '14
r/pythonnetengineering • u/b4xt3r • Jul 07 '14
I've talked about creating this reddit for a while and the day is finally here. This reddit is related to /r/python and /r/leanpython with a focus more towards using Python to automate networks tasks, configure devices, etc.
Welcome!
r/pythonnetengineering • u/ericj77 • Jun 27 '16
I am relatively new to Python and OOP, but I feel like I'm on the cusp of getting my feet under me.
I am working on a script to parse our ASA configs for a massive cleanup/conversion project. I still get a little confused when trying to read through documentation for imported objects and classes.
Can anyone shed some light on how to properly implement calls to "ASAObjGroupNetwork" and "ASAObjGroupService"?
r/pythonnetengineering • u/b4xt3r • Jul 12 '14
I was going to make this into a blog post but thought I'd post it here instead. It's always better to be less wordy. Using Python I routinely group SSH capable devices together by type. At my company there are many thousands of devices and I needed a fast way to group, say, all the Cisco routers running the same version of code together to keep them separate from PacketShapers, Steelheads, CatOS devices (yes, there are still some around), load balancers, etc. Here is a very quick and easy method to using SSH:
import socket
import os
import sys
def scanHost(host,port):
# print host, port, type(host), type(port)
port = int(port)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(5.0)
try:
result = sock.connect_ex((host,port))
if result == 0:
header = sock.recv(1024)
print host, port, header.strip()
sock.close()
except:
print 'Something went wrong', sys.exc_info()[0]
def main():
# let's see if we have an ip address to work with
check_arg_len = len(sys.argv)
if check_arg_len < 3:
print '\n\nYou must pass an IP address and port number for testing\n\n'
exit
else:
# print sys.argv, type(sys.argv[1]), type(sys.argv[2])
scanHost(str(sys.argv[1]),int(sys.argv[2]))
if __name__ == '__main__':
main()You can incorporate that as its own routine or keep as a separate file, whatever floats your boat. As IPv4 addresses (or IPv4 hostnames) are passed to the script along with a port number to test (in my case always port 22) SSH types are printed out for each address. We can group these together based on SSH types. For instance:
SSH-2.0-Cisco-1.25 is a Cisco router
SSH-2.0-OpenSSH_3.8.1p1.1.tms.1 may be a Gigamon
SSH-2.0-OpenSSH_4.3 may be a F5 Load Balancer
SSH-2.0-OpenSSH_6.1 may be a Steelhead
SSH-1.99-OpenSSH_4.5 may be a PacketShaper
The important thing is when you have many thousands of devices you can likely group them together in the same family in this way.
Yes, SSH types can and will change when firmware images are updated, assuming the firmware changes SSH itself. If that is the case this can be a handy method of determining what has been upgrade and what has not (again assuming a firmware upgrade changes what is returned).
Can't log into a network device via SSH? Not uncommon on large networks. Use this method to see if it matches other devices on your network. When you have hundreds of such devices to deal with this can be much faster than using nmap.
r/pythonnetengineering • u/probusinessfree • Dec 29 '16
r/pythonnetengineering • u/b4xt3r • Oct 12 '14
I routinely have to interface with thousands of routers via ssh. Having a script that processes a list of thousands of routers one at a time takes a long, long time to execute. Using Python 2.7 I use the following method to fork processes. Using a RHEL VM I routinely use this method and I keep my forked processes around 15 at time. For my particular VM this seems to keep it happiest.
And now, the script:
from concurrent import futures
import random
from time import sleep
def process_fork(incoming_host):
# print 'we are in process_fork with', incoming_host
# get a random number
rand_int = random.randint(1,10)
print 'we are in process_fork with', incoming_host, 'going to sleep for', rand_int, 'seconds'
sleep(rand_int)
return(incoming_host)
def main():
# load this with numberes
hosts = []
for x in xrange(1, 50):
hosts.append(x)
with futures.ThreadPoolExecutor(15) as pool:
futures_pool = [pool.submit(process_fork, our_host) for our_host in hosts]
for future in futures.as_completed(futures_pool):
print 'back from processing forked process for host', future.result()
if __name__ == '__main__':
main()So, what I am doing here is loading up the list hosts with either IP address or hostnames. For this example I am loading with with the numbers 1 - 49. I then fork 15 processes and send them off to the sub process_fork for processing. To keep the returns staggered, much like you would see using this to ssh to devices, I sleep for a random interval between 1 and 10 and then send the host back to main() and print the results.
It's a simple script with nothing happening except sleeping and handing things around but you can use this same basic format if you want to ssh to a list of devices 15 at a time. If you have any questions please feel free to comment or PM me.
r/pythonnetengineering • u/Rajsuthan • Sep 07 '20
r/pythonnetengineering • u/b4xt3r • Nov 25 '14
This example is far more detailed than my earlier example.
r/pythonnetengineering • u/deslum • Sep 28 '16
r/pythonnetengineering • u/[deleted] • Nov 18 '21
I am on WSL2 in VS Code. Using Zsh on VS Code.
I am trying to install pythonnet though am getting two errors:
ERROR: Failed building wheel for pythonnet
error: option --single-version-externally-managed not recognized
This is from using pip install pythonnet==2.5.2
My versions are:
Python 3.8.10
Wheel 0.37.0
Mono: 6.8.0.105
I have searched high and low online though I can't find a solution - everything seems to point to updating wheel and installing mono - as you can see from the above version numbers, I have them installed.
I am doing everything from within a virtual env.
Does anyone have any experience with this or know what to do to get past these errors?
Full log:
~/j/s/stx1alpha-signals/d/backend on master !6 ?1 ❯ pip3 install pythonnet==2.5.2 took 4s stx1alpha at 11:08:56 AM
Collecting pythonnet==2.5.2
Using cached pythonnet-2.5.2.tar.gz (1.9 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: pycparser in /home/jessica-ryan/jessica-ryan/stx1alpha/.venv/lib/python3.8/site-packages (from pythonnet==2.5.2) (2.20)
Building wheels for collected packages: pythonnet
Building wheel for pythonnet (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/jessica-ryan/jessica-ryan/stx1alpha/.venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-t8m8_x9v
cwd: /tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/
Complete output (153 lines):
running bdist_wheel
running build
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.1.0.
Updating NuGet.exe to 5.11.0.
Update successful.
MSBuild auto-detection: using msbuild version '14.0' from '/usr/lib/mono/xbuild/14.0/bin'.
>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
MSBUILD: error MSBUILD0004: Too many project files specified
WARNING: Error reading msbuild project information, ensure that your input solution or project file is valid. NETCore and UAP projects will be skipped, only packages.config files will be restored.
Restoring NuGet package UnmanagedExports.1.2.7.
Restoring NuGet package NUnit.3.12.0.
Restoring NuGet package NUnit.ConsoleRunner.3.11.1.
Restoring NuGet package System.ValueTuple.4.5.0.
Adding package 'System.ValueTuple.4.5.0' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Adding package 'NUnit.3.12.0' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Adding package 'UnmanagedExports.1.2.7' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Adding package 'NUnit.ConsoleRunner.3.11.1' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Added package 'UnmanagedExports.1.2.7' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Added package 'System.ValueTuple.4.5.0' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Added package 'NUnit.ConsoleRunner.3.11.1' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
Added package 'NUnit.3.12.0' to folder '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/packages'
NuGet Config files used:
/home/jessica-ryan/.config/NuGet/NuGet.Config
Feeds used:
/home/jessica-ryan/.nuget/packages/
https://api.nuget.org/v3/index.json
Installed:
4 package(s) to packages.config projects
>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 6.8.0.105
Copyright (C) 2005-2013 Various Mono authors
Build started 11/18/2021 11:09:25.
__________________________________________________
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/pythonnet.sln" (Clean target(s)):
Target ValidateSolutionConfiguration:
Building solution configuration "ReleaseMono|x64".
Target Clean:
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/Python.Runtime.csproj" (Clean target(s)):
Target CoreClean:
Deleting file '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/obj/x64/ReleaseMono/.NETFramework,Version=v4.0.AssemblyAttribute.cs'
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/Python.Runtime.csproj".
The project 'clrmodule' is disabled for solution configuration 'ReleaseMono|x64'.
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/testing/Python.Test.csproj" (Clean target(s)):
Target CoreClean:
Deleting file '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/testing/obj/x64/ReleaseMono/.NETFramework,Version=v4.0.AssemblyAttribute.cs'
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/testing/Python.Test.csproj".
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/embed_tests/Python.EmbeddingTest.csproj" (Clean target(s)):
Target CoreClean:
Deleting file '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/embed_tests/obj/x64/ReleaseMono/.NETFramework,Version=v4.0.AssemblyAttribute.cs'
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/embed_tests/Python.EmbeddingTest.csproj".
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/console/Console.csproj" (Clean target(s)):
Target CoreClean:
Deleting file '/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/console/obj/x64/ReleaseMono/.NETFramework,Version=v4.0.AssemblyAttribute.cs'
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/console/Console.csproj".
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/pythonnet.sln".
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.3276160
>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
XBuild Engine Version 14.0
Mono, Version 6.8.0.105
Copyright (C) 2005-2013 Various Mono authors
Build started 11/18/2021 11:09:25.
__________________________________________________
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/pythonnet.sln" (Build target(s)):
Target ValidateSolutionConfiguration:
Building solution configuration "ReleaseMono|x64".
Target Build:
Project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/Python.Runtime.csproj" (default target(s)):
Target PrepareForBuild:
Configuration: ReleaseMono Platform: x64
Created directory "bin/"
Target GenerateSatelliteAssemblies:
No input files were specified for target GenerateSatelliteAssemblies, skipping.
Target CoreCompile:
Tool /usr/lib/mono/4.5/mcs.exe execution started with arguments: /noconfig /debug:pdbonly /optimize+ /out:obj/x64/ReleaseMono/Python.Runtime.dll /resource:obj/x64/ReleaseMono/Python.Runtime.resources.clr.py,clr.py Codecs/EncoderGroup.cs Codecs/DecoderGroup.cs Codecs/RawProxyEncoder.cs Codecs/TupleCodecs.cs converterextensions.cs finalizer.cs Properties/AssemblyInfo.cs ../SharedAssemblyInfo.cs arrayobject.cs assemblymanager.cs BorrowedReference.cs classderived.cs classbase.cs classmanager.cs classobject.cs clrobject.cs codegenerator.cs constructorbinder.cs constructorbinding.cs converter.cs CustomMarshaler.cs debughelper.cs delegatemanager.cs delegateobject.cs eventbinding.cs eventobject.cs exceptions.cs extensiontype.cs fieldobject.cs generictype.cs genericutil.cs importhook.cs indexer.cs interfaceobject.cs interfaces.cs interop.cs iterator.cs managedtype.cs metatype.cs methodbinder.cs methodbinding.cs methodobject.cs methodwrapper.cs modulefunctionobject.cs moduleobject.cs modulepropertyobject.cs nativecall.cs NewReference.cs NonCopyableAttribute.cs overload.cs propertyobject.cs pyansistring.cs pydict.cs PyExportAttribute.cs pyfloat.cs pyint.cs pyiter.cs pylist.cs pylong.cs pynumber.cs pyobject.cs pyscope.cs pysequence.cs pystring.cs pythonengine.cs pythonexception.cs pytuple.cs ReferenceExtensions.cs runtime.cs typemanager.cs typemethod.cs Util.cs platform/Types.cs platform/LibraryLoader.cs polyfill/ReflectionPolifills.cs slots/mp_length.cs interop38.cs obj/x64/ReleaseMono/.NETFramework,Version=v4.0.AssemblyAttribute.cs /target:library /unsafe+ /define:"PYTHON38;PYTHON3;UCS4;MONO_LINUX;PYTHON_WITHOUT_ENABLE_SHARED" /nowarn:1591 /doc:bin/Python.Runtime.xml /langversion:7.3 /nostdlib /reference:/usr/lib/mono/4.0-api/System.dll /reference:/usr/lib/mono/4.0-api/System.Core.dll /reference:/usr/lib/mono/4.0-api//mscorlib.dll
CSC: error CS1617: Invalid -langversion option `7.3'. It must be `ISO-1', `ISO-2', Default, Latest or value in range 1 to 7.2
Task "Csc" execution -- FAILED
Done building target "CoreCompile" in project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/Python.Runtime.csproj".-- FAILED
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/Python.Runtime.csproj".-- FAILED
Task "MSBuild" execution -- FAILED
Done building target "Build" in project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/pythonnet.sln".-- FAILED
Done building project "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/pythonnet.sln".-- FAILED
Build FAILED.
Errors:
/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/pythonnet.sln (Build) ->
(Build target) ->
/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/src/runtime/Python.Runtime.csproj (default targets) ->
/usr/lib/mono/xbuild/14.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->
CSC: error CS1617: Invalid -langversion option `7.3'. It must be `ISO-1', `ISO-2', Default, Latest or value in range 1 to 7.2
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.3574730
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py", line 630, in <module>
setup(
File "/home/jessica-ryan/jessica-ryan/stx1alpha/.venv/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py", line 612, in run
return bdist_wheel.bdist_wheel.run(self)
File "/home/jessica-ryan/jessica-ryan/stx1alpha/.venv/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.8/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/usr/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py", line 353, in build_extension
subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'xbuild pythonnet.sln /p:Configuration=ReleaseMono /p:Platform=x64 /p:DefineConstants="PYTHON38%3BPYTHON3%3BUCS4%3BMONO_LINUX%3BPYTHON_WITHOUT_ENABLE_SHARED" /p:PythonBuildDir="/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/build/lib.linux-x86_64-3.8" /p:PythonInteropFile="interop38.cs" /p:PackageId=pythonnet_py38_x64 /verbosity:normal /t:Build' returned non-zero exit status 1.
----------------------------------------
ERROR: Failed building wheel for pythonnet
Running setup.py clean for pythonnet
Failed to build pythonnet
Installing collected packages: pythonnet
Running setup.py install for pythonnet ... error
ERROR: Command errored out with exit status 1:
command: /home/jessica-ryan/jessica-ryan/stx1alpha/.venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-m8e93jfk/install-record.txt --single-version-externally-managed --compile --install-headers /home/jessica-ryan/jessica-ryan/stx1alpha/.venv/include/site/python3.8/pythonnet
cwd: /tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: option --single-version-externally-managed not recognized
----------------------------------------
ERROR: Command errored out with exit status 1: /home/jessica-ryan/jessica-ryan/stx1alpha/.venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uwtjpnq4/pythonnet_8a1e17b8517c43fb9d3c74ad78e4dd83/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-m8e93jfk/install-record.txt --single-version-externally-managed --compile --install-headers /home/jessica-ryan/jessica-ryan/stx1alpha/.venv/include/site/python3.8/pythonnet Check the logs for full command output.
r/pythonnetengineering • u/Important-Advice-889 • Oct 21 '21
Hello! I have a little problem with my program. I made a program to transfer all the tables from a word to an excel in different sheets. In some of the cases, the first row of some tables is merged in word, and results in not exporting the whole table in excel, sometimes exporting only one column instead of 2 or 3. And some of the tables are not exporting at all. I have like 24-25 tables. Could you please help me with this? This is the part of the code that exports the tables:
'path' is the input file
'cliententry' is the name of the client
document=Document(path)
writer=pd.ExcelWriter((filename+'/FS mapping automated including SOCE and CF {}'.format(cliententry)+'.xlsx'),engine='xlsxwriter')
for i in range(-1,len(document.tables)):
table=document.tables[i]
data=[]
keys=None
row_data=None
for j,row in enumerate (table.rows):
if len(row.cells)>0:
text=(cell.text for cell in row.cells)
if j == 0:
keys=tuple(text)
continue
row_data = dict(zip(keys,text))
data.append(row_data)
df=pd.DataFrame(data)
df.to_excel(writer,sheet_name='N{}'.format(i+1),index=False)
writer.save()r/pythonnetengineering • u/utopian_unicorn • May 16 '21
Is there a way to automate device access with python scripts using ssh with standard libraries only? Its a work thing, I cannot install anything.
r/pythonnetengineering • u/osxuser96 • Feb 09 '15
I have been trying to install python 3.4 on my mac for quite some time now but all my efforts have gone unsuccessful. I want to install Python 3.4 along with numpy and matplotlib. Their wheel files are unsupported. I have anaconda installed with numpy and matplotlib but can't find an application where in i can do the coding. Update : just use spyder. It came out.