Search within files in search result in Sublime - sublimetext2

I often use Sublime Text 2's search all open files/folders feature (CMD+SHIFT+F).
Is it possible to perform a second search that only queries files which contain the first search query?
For example: Search 1 finds 5 files that contain "hello". Search 2 should only query those same 5 files for "world", so the resulting matches will be files which contain both "hello" and "world".
I can search the text which is visible in the results buffer (such as in the screenshot below), but I'd like to search the entire contents of all files that are shown in the results buffer.

1:
Open the find_in_files panel with Ctrl + Shift + F.
In the example, <open folders> is used for the Where: argument, but you can use whatever fits your initial search criteria.
2:
Open the find panel with Ctrl + F while you are still in the results buffer.
Enter ^(/Users/.*)(?=:$) as your Find: argument, and make sure the RegEx switch is enabled. This RegEx pattern will match all of the paths within the results.
( Windows users can enter ^(C:\\.*)(?=:$) )
Copy the selected paths.
3:
Paste the copied paths into a blank document.
Open the replace panel with Ctrl + H.
Enter ^(/Users/.*)(\n) as the Find What: argument, and $1$2,  as the Replace With: argument. This will effectively convert all of the lines into a single line of comma separated values.
( Windows users can enter ^(C:\\.*)(\n) )
Copy the resulting line.
4:
Open the find_in_files panel with Ctrl + Shift + F.
Paste the copied path list as your Where: argument, and enter your second query as the Find: argument.
5:
Repeat as necessary.

Related

AppleScript get variable from a specific column in a TSV file

I am new when it comes to using AppleScript, and I need you help with the following:
I have a TSV file formatted like this:
[COLUMN A] [COLUMN B] [COLUMN C] [COLUMN D] (...)
[Line 1]Data Data Data Data
[Line 2]Data Data Data Data
(...)
I would like, for each line of the file, to perform a new Google Image search. The keywords would be taken from let's say column A and D, but not from column B or C.
I managed to create a script that opens the file, and performs the search, so my problem is "only" to be able to use some specific columns, not all of them (which is what I am doing with my current script).
Here is my script:
set thetext to read (choose file)
repeat with line_number from 1 to count of paragraphs in thetext
set line_text to paragraph line_number of thetext
tell application "Google Chrome"
activate
tell front window to make new tab at after (get active tab) with properties {URL:"http://images.google.com/images?ie=ISO-8859-1&hl=en&btnG=Google+Search&q=" & line_text}
end tell
end repeat
How would you do to "split the line" (line_text in the script) and use only specific columns for the search ? It is a TSV file so it uses tabulations between the columns of data.
Thank you :)
That's what the text item delimiters are for. Your line_text is a string in the form "Data1\tData2\tData3\tData4", so let's use that as an example:
set line_text to "Data1\tData2\tData3\tData4"
set the text item delimiters to "\t"
set theData to every text item of line_text
Result:
{"Data1", "Data2", "Data3", "Data4"}
Now if you want the fourth column data for that line you just ask for item 4 of theData.

Value is repeated after copying it from Access and pasting it into Notepad++

I open a table inside the GUI of MS Access. I mark a cell which contains:
Myriam
I hit ctrl + c to copy it. I open a new document in Notepad++ and copy with strg + v. The result is:
"Myriam
Myriam"
I get two lines instead of one! There are 27 thousand entries in that column and ONLY for this one I observe this behaviour. I was able to track it down to this level, but now I'm clueless about the 'why' ... ?
Using the "Zoom" feature (ShiftF2) in Access revealed that the field actually did contain
Myriam
Myriam
This was probably due to a user accidentally hitting CtrlEnter during data entry, which added the newline and made the field look empty, so they typed the name in a second time.

How to search multiple files of specific file type within Sublime Text 3

I would like to search for a string within all *.php files in a certain directory (and its sub-directories) using the Shift + Ctrl + F search dialog.
My guess was to set the search location to:
c:\example\*.php
but that gives an error:
Unable to open c:\example\*.php
Is there a way to perform the search I'm hoping to perform?
C:\example,*.php
In the Where: click ..., select Add Folder, after that select Add Include Filter

Search file names that contain a string

I have a module named flume and file names that include that module name, like flumeIndexController, flumePlugin etc. Now I've decided to rename the module to oozie so I want to have these files renamed to include new module's name like oozieIndexController, ooziePlugin.
How can I get a list of files than include the flume string (in file name) possibly using built-in search or through any other option?
Navigate | File... Ctrl + Shift + N using Default keymap.
You can narrow your search results (just specify parts of the path, e.g. /abc/ and it will show results in a folders that match such pattern/abbreviation). Alternatively -- just do a post-filtering by excluding unwanted results (see below).
This window has only 2 buttons -- one of which will display results in a more traditional and permanent "Search results" tool window (the one that you see when you do Find in Path and alike).

Parse tab separated text file in Google Sheets

I have a txt file available on the web which contains tab separated values (TSV/CSV) like this:
Product_IdtabColortabPricetabQuantityItem1 tabRed tab$5.2 tab5Item2 tabBlue tab$7.5 tab10
I imported the txt file into a Google Spreadsheet using the IMPORTDATA(url) formula. The problem is that now I need to split the text to columns. I tried the following formulas without success:
Split(A1,"\t")
Split(A1," ")
Split(A1,"<tab>")
another thing I tried is to to use the Substitute function, but I just can't figure out how to match the Tab character in Google Spreadsheets?
Pages strips tabs by default when you paste text using a standard paste. Tab delimited data can be pasted and automatically parsed using:
Right Click -> Paste special -> Paste values only
IMPORTDATA(url) seems to handle tabs automatically, as others have mentioned before, if the URL ends in ".tsv".
I had trouble trying to import a file from Dropbox even though the file was named "something.tsv", because the url was
"https://www.dropbox.com/s/xxxxxxx/something.tsv?dl=1"
I managed to solve the problem by adding a dummy query parameter to the url:
"https://www.dropbox.com/s/xxxxxxx/something.tsv?dl=1&x=.tsv"
NOTE: I know this question was asked back in 2014 and I am answering this question some 5 years later. I am posting the answer here in hopes that someone else who googles their way here will be saved the headache and can be helped by how I devised a solution.
SUMMARY OF THE ISSUE: By default the IMPORTDATA() function will properly process a tab-delimited file only if the file name ends with the extension .TSV
UPDATE Nov 14, 2019:
In a comment below, Poul shared that he has found an undocumented parameter for the IMPORTDATA() function by which you can specify the delimiter to split the data. As of writing this, the official documentation makes no reference to this delimiter.
In effect the documentation should look something like the following:
IMPORTDATA("url","delimiter")
So, if you wanted to force a file to be split on the TAB character, it would look something like
IMPORTDATA("url","\t")
PRIOR ANSWER:
UPDATE: I am leaving my original answer just in case it might be helpful if the answer above, which includes undocumented functionality, does not continue to work.
ORIGINAL ANSWER: After seemingly countless attempts, I figured out how to coax Google Sheets into importing a tab-delimited file regardless of the extension.
For those looking for the quick and dirty answer, copy the following into a cell of a Google Sheet to give it a try:
=ARRAYFORMULA(IFERROR(SPLIT(IMPORTDATA("https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3_Latin1.tab"),CHAR(9),FALSE,FALSE)))
For those that want to know a bit more, I will try to explain how each of the nested functions are helping to create the final solution:
=ARRAYFORMULA( IFERROR( SPLIT( IMPORTDATA(URL-HERE) ,CHAR(9),FALSE,FALSE) ) )
IMPORTDATA() - the primary function that pulls in the data file from the web
SPLIT - split the row by tab, note the use of char(09) to generate the tab character; also note the use of FALSE for the last parameter which was required in my case to ensure empty cells were not collapsed together
IFERROR - used to catch situations where an import might fail, the error will be trapped and not returned to the spreadsheet
ARRAYFORMULA - this function ensures that every line in the file is parsed; without this, only the first line of the file would be returned to the spreadsheet
It turns out that IMPORTDATA(url) can import a tab separated file, but it expects the file name to have the .tsv extension. This is inconsistent with Excel, where a tab-separated export results in *.txt.
If you can ensure that you use a .tsv extension, then your problem is solved.
You can also use the Sheets UI to import the file (into a new Spreadsheet). Select File > Import..., then Upload > Select a file from your computer. When the file selection dialog opens, paste the URL into the file name field, and click Open. The file will be downloaded to your PC then uploaded to Drive, through the Import dialog that will let you choose the delimiter.
(Validated on Windows 8.1 with Chrome; I don't know how this will behave on other OSes or browsers.)
Edit: See this gist.
importFromCSV(string fileName, string sheetName)
Populates a sheet with contents read from a CSV file located in the user's GDrive. If either parameter is not provided, the function will open inputBoxes to obtain them interactively.
Automatically detects tab or comma delimited input.
I had luck using split() and indicating only a single space as the delimiter, even though the data i pasted in had tabs separating each "column": =SPLIT(A1, " ", True) where A1 had data separated by 1 or more spaces. It seems that pasting in TSV data results in conversion from tabs to spaces.
This could be done in two steps leveraging the fact that tab is essentially multiple spaces.
Steps are as follows:
Select the columns which have tab separated data. Then trim tab to single space by using Data -> Data cleanup -> Trim whitespaces.
Now usual Data -> Split text to columns should work out of the box or after selecting space as separator.