I'm using xlwings to expose python functions as user defined functions within Excel. It works perfectly if the excel file is in the same directory as the .py file which contains my UDF functions.
I would like to save my Excel file anywhere and just update my xlwings.conf file to have the location of the python module which contains the udf definitions.
If I set the conf file to have
"UDF MODULES","C:\src\xlwings_wrapper\xlwings_udfs"
I get the following error ModuleNotFound: No module named 'C:\src\xlwings_wrapper\xlwings_udfs'. How ever I have checked and the xlwings_udfs.py file is in that location.
Does anyone know if setting an absolute path for the UDF Modules is supported by xlwings?
Thanks
David
Have a look at the docs where the settings are explained: The UDF_MODULES only accept the module name. The path to where the modules are is set (and explained) under PYTHONPATH. So in your example you have to set the following:
"UDF MODULES","name_of_module"
"PYTHONPATH","C:\src\xlwings_wrapper\xlwings_udfs"
I made the same mistake. Should have read the manual
For completeness, when using either the xlwings.conf sheet or the UDF module box on the ribbon you need to adopt this setting configuration.
Related
I have a large number of auto generated code files that are identifiable by the having _pb2 in the file name.
When I search using PyCharm CTRL+Shift+F I can use a file mask. I would like for instance to find all Python files *.py that do not have _pb2 in their name. Is there a way to achieve that?
You can include and exclude files and directories by creating a Custom Scope that filters using a combination of filename wildcards.
Ctrl+Shift+F to open "Find in Path".
Create a new Custom Scope following steps 2-4 in the screenshot.
Enter the pattern, for your specification it would be file[Project_Name]:*.py&&!file:*_pb2*
Afterwards the search results are restricted to within the Custom Scope.
Source at JetBrains official site: "Scope configuration controls"
I would like to import other python/csv files into my python udf to perform some operations.
Like,
Comparing the table data(which flows in as a stream, row by row) to an external .csv row.
When I try to read data of .csv file, it gives me an error
IOError: File /home/abc/xyz/myfile.csv does not exist
While the code works perfectly well when it is written as a regular python script (not like udf)
If I understood it right . You can try
ADD FILE [Your complete file path]
or
Add FILES [Your directory path].
Because before referring anything on cluster you must add it to the distribution cache so that code there can access that portion.
you can have a look at it.
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Cli
Be careful about the syntax! It may cause many problems and unfortunately, query language interpreter is not able to show where the problem is coming from and it just shows some generic error report.
Look at kind of the same problem here that was caused by a syntax issue in addressing the file!
Accessing external file in Python UDF
I want to change the default directory listing of the pythonwebkit(the one imported from gi.repository) for an application I am working on. Is there any function/script in webkit that does the job?
EDIT
The code for styling the default directory listing is in the file net/base/dir_header.html and ends up in chrome.pak and chrome_100_percent.pak.
The python module data_pack.py can work with these files.
If you want to filter certain file types from the list, you can probably do that in addRow()
You will have to use os.chdir() to change the current directory for the whole process. AFAIK, WebKit doesn't keep an internal environment for things like the current folder.
In python, I'm using win32api to read and write INI settings as and when they are required into specific sections based on IDs.
Once I have finished with the section, I want to be able to delete the entire section from the INI file. How would I go about doing this using the win32api python library?
My proposal is to use native Python module for handling INI files ConfigParser. Have you tried it already? It has remove_section method that probably will work for you.
This is not a Python specific answer, but look into calling WritePrivateProfileString with the lpKeyName parameter set to NULL. With this parameter set to NULL the entire section named in lpAppName, including all entries within the section, is deleted.
I am currently trying to use Babel to generate a set of static html pages in different languages using Jinja2 within a simple script (not as part of a web app)
I am at the point where I need to extract the messages for translation and I know that I am supposed to modify the Babel mapping configuration file to understand Jinja2 templates.Since I am using the commandline tool, I assume I need to create the mapping file myself.
However, I can't seem to find in the documentation what the mapping configuration file should be named and where it should be placed. All I know is that I need to place the following:
[jinja2: **/templates/**.html]
encoding = utf-8
into the mapping file according to the Jinja2 documentation. Has anyone done something similar or know what the mapping configuration file should be? Thanks!
You can specify the location of the configuration file with -c <filename>.
Mapping file location is read from setup.cfg file (generated by Distutils), in the section "extract_messages". In this section you must add setting named mapping_file, which should point to Your mapping file.
Example:
This tells Babel to look for mapping file named message-extraction.ini in package directory.
[extract_messages]
# some default options
# ..
mapping_file = message-extraction.ini
You can specify the path to the mapping configuration file for extract_messages using -F. For example, my mapping configuration is in babel.cfg, located at the root of my project. When extracting messages, I run:
pybabel extract -F babel.cfg ...