If I merge multiple cells in a Jupyter notebook, there is a blank line between the code from each cell.
Can I merge cells without this blank line?
No, this is the expected behavior.
Here is the source for mergeCells
Here is the line that joins the contents toMerge
newModel.value.text = toMerge.join('\n\n');
const toMerge: string[] = [];
Note, there are 2 new lines, '\n' in the .join(), therefore the answer to Can I merge cells without this blank line? is no, unless you do a PR for the project, change the desired line, compile and run it on your system.
Related
I am trying to parse a pdf using PyPDF2 in a Jupyter notebook. Below is how I would like to write the different parts of the code, that is, the extract text statements in one cell and the RegEx in a new cell. However, if I separate the two pieces of code as below, the RegEx only runs through the last page of the file and not through the whole file (12 pages). Why does this happen? I would really like to use different cells.
import PyPDF2
import re
file = open(r'file.pdf', 'rb')
doc = PyPDF2.PdfFileReader(file)
#print(doc.getNumPages())
#new cell
for i in range(0, 12):
page = doc.getPage(i)
text = page.extractText()
#print(text)
#new cell
doc_re = re.compile(r'S\d+_\d+', re.IGNORECASE)
result = doc_re.findall(text)
print(result)
Each time you run your for loop, you're resetting the value of text by using text = page.extractText()
The RegEx is running on what you give it, which is text. Even though your loop runs over 12 pages, the second cell of code receives the final value of text (which is whatever you assign it to be on the last iteration of the loop).
You can either move the code from your second cell inside of your for loop, or a better option would be to add each page's text to text.
So, turning text = into text += should solve your problem.
How can I copy multiple cells from one jupyter notebook to another notebook at once, and the cells will not merge after pasting?
I have tried this solution, in which shift+Up/Down are used for selection, cmd⌘+c and cmd⌘+v are used for copying and pasting. However, the cells will merge after pasting.
Is there a way to prevent the cells from merging?
Thanks for the tips. I tried and found the way not to merge:
Press esc key (command mode, the area will turn to blue), 2) use shift+up/down to choose(all turn to blue area) 3) cmd⌘+c to copy
Another notebook( you will paste), also press esc key first( that's how not merge) and cmd⌘+v to paste the multi cells, you will get multi cells, including outputs.
The cells do not seem to merge, using Jupyter Lab version 2.1.5.
Click on the left of the top cell you'd like to copy.
Press the Shift key and click on the bottom cell you'd like to copy.
The sequence of cells should be highlighted now (in light blue with the usual theme)
Press the C key to copy
Select the cell above the cell you want the new cells to appear.
Press the V key to paste
Result (note that the new cells will have numbers matching the old ones):
After spending a few hours trying to figure this out (From questions already asked and other places), I'm still stuck on it. The goal is to read from a text file (Have that working), line by line (Not working). As it stands, this is my latest attempt:
With open("Product.txt","r") as file:
for i in file:
lineRead = file.readline()
productSplit = lineRead.split(",")
productNameList.append(productSplit[0])
productCostList.append(productSplit[1])
productPriceList.append(productSplit[2])
What I am trying to do:
Read the text file line-by-line.
Split the result on commas.
Assign values at specific indexes to specific lists.
I'm not really sure how to use readline, and I couldn't understand it from the documentation, nor the other questions. I think that's where my problem is. I'd appreciate being told what I'm doing wrong. And as a side note, could I read in the whole file, split on the new line, and then split those indexes on commas?
productNameList = []
productCostList = []
productPriceList = []
With open("Product.txt","r") as file:
for line in file:
productSplit = line.split(",")
productNameList += [productSplit[0]]
productCostList += [productSplit[1]]
productPriceList += [productSplit[2]]
I'm importing an .xls file using the following connection string:
If _
SetDBConnect( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath & _
";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""", True) Then
This has been working well for parsing through several Excel files that I've come across. However, with this particular file, when I SELECT * into a DataTable, there is a whole column of data, Item Description, missing from the DataTable. Why?
Here are some things that may set this particular workbook apart from the others that I've been working with:
The workbook has a freeze pane consisting of the first 24 rows (however, all of these rows appear in the DataTable)
There is some weird cell highlighting going on throughout the workbook
That's pretty much it. I can't see anything that would make the Item Description column not import correctly. Its data is comprised of all Strings that really have no special characters apart from &. Additionally, each data entry in this column is a maximum of 20 characters. What is happening? Is there any other way I can get all of the data? Keep in mind I have to use the original file and I cannot alter it, as I want this to ultimately be an automated process.
Thanks!
Some initial thoughts/questions: Is the missing column the very first column? What happens if you remove the space within "Item Description"? Stupid question, but does that column have a column header?
-- EDIT 1 --
If you delete that column, does the problem move to another column (the new index 4), or is the file complete. My reason for asking this -- is the problem specific to data in that column/header, or is the problem more general, on index 4.
-- EDIT 2 --
Ok, so since we know it's that column, we know it's either the header, or the rows. Let's concentrate on rows for now. Start with that ampersand; dump it, and see what happens. Next, work with the first 50% of rows. Does deleting that subset affect anything? What about the latter 50% of rows? If one of those subsets changes the result, you ought to be able to narrow it down to an individual row (hopefully not plural) by halfing your selection each time.
My guess is that you're going to find a unicode character or something else funky is one of the cells. Maybe there's a formula or, as you mentioned, some of that "weird cell highlighting."
It's been years since I worked with excel access, but I recall some problems with excel grouping content into some areas that would act as table inside each sheet. Try copy/paste the content from the problematic sheet to a new workbook and connect to that workbook. If this works you may be able to investigate a bit further about areas.
I'm trying to figure out how to define a new text editing keystroke in Xcode 4.
To pick one example, Xcode does not appear to have the incredibly useful Emacs join-line function: delete the newline between the current line and the previous line AND ALSO delete any excess indentation whitespace at the beginning of the current line. ie, go in one keystroke from this:
_measurement =
[DPLMeasurement newWithDate:measureDate inManagedObjectContext:[datastore managedObjectContext]];
to this:
_measurement = [DPLMeasurement newWithDate:measureDate inManagedObjectContext:[datastore managedObjectContext]];
and NOT this:
_measurement = [DPLMeasurement newWithDate:measureDate inManagedObjectContext:[datastore managedObjectContext]];
I've seen instructions for user scripts that were apparently for Xcode 3. Does Xcode 4 no longer have anything like this?
Halley's answer to this question does ALMOST what I want:
Xcode duplicate line
Add the following to the plist file, /Developer/Library/PrivateFrameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist:
Join Previous Line
String
moveToBeginningOfLine:, moveWordRight:, moveWordLeft:, deleteToBeginningOfLine:, deleteBackward:
I say "almost" because it joins the two lines, and deletes whitespace at the beginning of the second line, but if the first line doesn't end with a space it just rams them together and I have to type in the required space. It also deletes punctuation (like open brackets) if they happen to fall at the beginning of the line. So I'm not quite there.