w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
php textfile=file("filepath.txt") - how to return the file array?
return aborts execution of the function and returns immediately the calling context. You cannot have multiple returns like that - it's literally impossible for the 2nd and further returns to EVER get executed. You can have a single return call and return an array of elements, e.g. function gather_info(...) { ... return array($in, $in2, $in3); } $foo = gather_info(...); $in = $foo[0]; $in2 = $foo[1]; etc...

Categories : PHP

How to open a file in Jsp using filepath
I think the .jsp files should be inside WebContent folder or one of its children. If the file, say index.jsp, is inside WebContent folder then the path is: /index.jsp If the file is in WebContent/SomeFolder then the path is: /SomeFolder/index.jsp

Categories : Java

Filepath copied after find-file
First step would be to know "who" is copying that into the clipboard. Is the window system clipboard we are talking about? If so, you can do (setq debug-on-error t) (fset 'x-set-selection nil) and then open a file. Hopefully the stack trace should give you a clue of what package is doing that.

Categories : Emacs

If column A in file 1 = column A in file 2, replace with column B from file 2
create dictionary from file2 with open('file2', 'r') as file2: replacement = {} for line in file2: splited_line = line.split() replacement[splited_line[4]] = splited_line[1] with open('file1', 'r') as file1: with open('file1_new', 'w') as file1_new: for line in file1: splitted_line = line.split() splitted_line[2] = replacement.get(splitted_line[1], splitted_line[1]) file1_new.write(' '.join(splitted_line)+' ')

Categories : Python

NSURL for a downloaded or otherwise obtained file to open an iOS app with: What is its filepath?
An NSURL that points to a file on the local file system is called a "file URL". To convert the NSURL to an NSString representing the file's path you use: NSString *filePath = [url path]; To check to see if an NSURL represents a file URL, use: BOOL isFileURL = [url isFileURL]; Keep in mind that if your app is passed a file URL, you will always have access to the file. There is no need to check if it starts with any prefix. Why would iOS pass you a file that you don't have access to?

Categories : IOS

Getting Error while downloading file: The process cannot access the file '[filepath]' because it is being used by another process
I figured out the problem. There was a small looking but a big mistake. I forgot to put below line at the end of my upload function: fileStream.Dispose(); Because I didn't disposed the stream object my file was still in use by that object and I think garbage collector was releasing my file after some time that is why I was able to download that later.

Categories : C#

How to align middle column in responsive 3-column structure?
Taking the JavaScript/JQuery approach, I'll provide an idea, but not the code itself. my code sections are not real code, but illustration of what need to be done. (except for the CSS part) first, we set the box-sizing of all the elements in page to be border-box, because its easier to calculate the sizes of the elements this way. * { -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */ } this means that the width of .col2 have to grow by 10px to support the 10px padding and stay like before. .col2 { width: 120px; } it will be best if the second column will always be next to the first one, so we will set the max-width of .col1 to support that behaviour. .co

Categories : HTML

Change project file structure after migrating from Eclipse to Android Studio gradle structure
While migrating your project from Eclipse to Android Studio, no change have been done on project structure. The only that have changed are new .iml and .gradle files. Your java code stays in project/src/ folder, and has not been moved in project/src/main/java folder (like in a new created project from AndroidStudio). Your AndroidManifest file also stays in the project/ folder and has not been moved in project/src/main/ folder (like in a new created project from AndroidStudio). At migration, the build.gradle file is customized in order to be able to compile with the old structure is described in the gradle documentation : Configuring the Structure For a new created project in AndroidStudio, the sourceSets part of the build.gradle file : sourceSets { main.java.srcDirs = ['src/java']

Categories : Android

Java read file line by line and replace nth column
I'd do this by putting each line into an arraylist, using split(",") on each line of the array, and replacing the 4th index in each array. To rejoin the array back into a string, you'd have to write your own function (Java doesn't have one built-in). There is another stack overflow question that addresses this problem, though. try { Scanner scanner = new Scanner(file); // initialize the arraylist, which will hold the split strings ArrayList<String[]> data = new ArrayList<String[]>(); while (scanner.hasNextLine()) { // filling the arraylist String line = scanner.nextLine(); String[] split = line.split(","); data.add(split); } scanner.close(); // replacing the v

Categories : Java

SQL Stored Procedure - replace a result column with value from existing table column
You want to join the two tables. ie: SELECT TOP 2000 CAST(datepart(day,TIME_STAMP) as char(2)) + '-' + CAST(datename(month,TIME_STAMP) as char(3)) + '-' + CAST(datepart(year,TIME_STAMP) as char(4))+ ' ' + CONVERT(varchar,TIME_STAMP,108) as 'TIME STAMP', [TAG], [DESCRIPTION], Events.Description, [SUBEVENTCODE] FROM [Arc_DB].[dbo].[LOG] inner join events on log.eventcode = events.event ORDER BY TIME_STAMP DESC

Categories : SQL

Replace text written in one column based on the content of another column?
You description is unclear, however, it appears that you are only putting 'unlimited' in the blank cells of column M if the corresponding value in column K is 1. If column M actually contains the text 'NULL' rather than being blank/empty, then the following won't work. Highlight the data in column M and chose the Home tab, Find & Select Group, and 'Go To Special' (or use Ctrl-G, Special..) Choose Blanks. This will select all blank cells in this range Type the following formula, using the mouse to click on the corresponding cell in column K. That is, for the same row of the currently active cell. =IF(K12=1,"unlimited","") You need to press Ctrl-Enter to fill this formula in all the currently selected cells. When complete, I assume that you'll want to highlight column M and Copy/ P

Categories : Excel

SQL Server: How to replace words in one column if/when the same word is found in another column?
I guess my question is "why keep the data in a list format after processing?". This format is not in normal form. I would create the following tables. raw_data ( user_id, food_list ) categories ( food_name, food_category ) processed_data ( user_id, food_category, food_cnt ) hospital_data ( user_id, unknown_name ) The raw_data table is the unprocessed data. I would use a string split function to parse the data into rows. Convert the data to same case and compare against food category. Any matches should be counted and saved in the processed_data(). Any left over names w/o match should be put in the hospital_data() table. These are miss spelled entries that need to be added to the category table. This solution would be a two pass run. 1 - Loads most of the data.

Categories : SQL

Which Data Structure provides Replace Operation when appending Duplicate?
std::set does so. In fact, if you want this not to happen, you need to switch to multisets. From the documentation of set Because elements in a set are unique, the insertion operation checks whether each inserted element is equivalent to an element already in the container, and if so, the element is not inserted, returning an iterator to this existing element (if the function returns a value).

Categories : C++

Regular expressions replace a.column to column
str_replace() doesn't allow regular expressions. You are confusing it with preg_replace(): echo preg_replace("/([a-z].)*(.+)/i", '$2', 'a.column');

Categories : PHP

CHCSVParser returns nil Array for valid filePath & valid csv file
So what counts as a "very big file" anyway? At which point is it prudent to use delegation over the simple 'arrayWithContentsofCSVFile'? The way that CHCSVParser reads and parses your CSV file is identical regardless of whether you're using the NSArray category method or directly interfacing with the delegate itself (you can see this for yourself here). So "a very big file" is really a CSV file which would be too large to hold in memory as an NSArray in its entirety. The memory consumption will depend both on the number of columns and the number of rows, so it's hard to give a definite limit. What this means is that the problems you get from using the -arrayWithContentsOfCSV with large files shouldn't manifest themselves as returning nil, but as low memory warnings and the like. The

Categories : Iphone

Search Replace in MySQL: remove directory structure but keep filename
Use substring_index select substring_index('http://www.example.com/dev/archive/examples/test.htm','/',-1) (both above are fully from MySQL String Last Index Of How you would use it is easy, but just to explain, you select the last index of the / and then do another substring function to cut off anything to the left of it

Categories : Mysql

Update a column with hierarchy structure in oracle
It looks like you're setting up the column for sorting, and you don't need to. Also, the query to set PcCode like you want to would be very difficult. Oracle's hierarchical queries will sort by the hierarchy if you use the ORDER SIBLINGS BY option. The following query will read your hierarchy and order it the way I believe you want it (I've added a "path" value to show the full hierarchy branch for each row, and how it sorts correctly with ORDER BY SIBLINGS): SELECT ID, Name, ParentID, SYS_CONNECT_BY_PATH(ID, '/') FROM service START WITH ParentID = 0 CONNECT BY PRIOR ID = ParentID ORDER SIBLINGS BY ID; When I ran this query I got the following results: ID NAME PARENTID SYS_CONNECT_BY_PATH(ID,'/') -- -------- -------- --------------------------- 1 Test1 0 /1

Categories : Oracle

Pandas Data Frame Column structure
One way is to make two DataFrames and concatenate them. df = pd.concat([DataFrame({'M': [1, 2], 'F': [2, 5]}), DataFrame({'M': [1, 5], 'F': [2, 7]})], axis=1, keys=['Completed', 'Not Completed']) df.index = ['A', 'B'] df.index.name = 'Name'

Categories : Python

How do I take the advantage of the variable column key/value structure of Cassandra
The Thrift API can create columns on-the-fly. For example in Astyanax you can insert columns which were not defined in the schema. But this will still leave your first 100 columns effectively with a null value for that column, so there's no real reason to avoid updating the schema and several downsides. This is why CQL enforces "tell the schema about it first." Now, if you have truly dynamic fields to deal with, you can use collections in CQL. But this is not the case in your example.

Categories : Cassandra

how to create a view of multiple columns from one column structure in oracle sql?
Assuming you always need 3 columns, then this will work using MAX with CASE to perform a pivot, along with ROW_NUMBER() and MOD(): SELECT MAX(CASE WHEN rn = 1 THEN name END) col1, MAX(CASE WHEN rn = 2 THEN name END) col2, MAX(CASE WHEN rn = 3 THEN name END) col3 FROM ( SELECT Row_Number() Over (Partition By MOD(ROWNUM,2) Order By Null) rn, MOD(ROWNUM,2) whichGroup, name FROM profile ) talias GROUP BY whichGroup Use MOD to get which rows and use Row_Number for your pivot. SQL Fiddle: http://sqlfiddle.com/#!4/46149/1 -- Please note, without adding a field to your ORDER BY clause, you won't be able to guarantee a specific order to the results.

Categories : SQL

Dynamic Multidimensional Java Structure to Replace Static Multidimensional Array
There's no multidimentional thing in Java.Java has array of arrays. You can use ArrayList with type parameter as ArrayList ArrayList<ArrayList<yourType>> myList = new ArrayList<ArrayList<yourType>>(); Also,don't worry about GC..It would collect as and when required..

Categories : Java

Stream (pointer to a file structure) in File handling giving strange values
You're opening the file in read-only mode: fopen("C:\Users\sshekha\Desktop\z.txt","r");. Here "r" says you only intend to read from file. To be able to write contents (i.e. fputs(...)), open the file in write mode like so: fopen("C:UserssshekhaDesktopz.txt","w")(or"a"` if you want to append). For more information, read fopen documentation. EDIT: I see that you've tried both read and write modes. You're code only shows read-mode and hence my assumption on the read-only problem. Let me do a bit more research and get back. Please write the following code in your if statement: perror("The following error occurred:"); if you don't have a console, use this to store the error string: char* errorCause = strerror(errno); MessageBoxA(m_hwndPreview, errorCause, "BTN WND", MB_ICONINFORMATION); a

Categories : C++

C language - record data (add,delete) in text file using file IO, structure, function, array, pointers
In Export_Profile() the profile variable is not set to appropriate value. void Export_Profile() //Export Staff Profile to Text { struct element profile; // this has not been set to actual value. ... fprintf(fPtr1," %10s %10s %10s %10s %10s", profile.id, profile.name, profile.gender, profile.phone, profile.email); .... } You may want to store data in some global variable or array of variables or linked list. Set them in New_Profile() and use them other functions like Export_Profile().

Categories : C

Find/Replace lines in SQL column
Try this solution: SET NOCOUNT ON; DECLARE @MyTable TABLE ( ID INT IDENTITY(1,1) PRIMARY KEY, OldContent NVARCHAR(MAX) NOT NULL, NewContent NVARCHAR(MAX) NULL ); INSERT INTO @MyTable (OldContent) VALUES (N'<p>Please refer to &lt;|Specific Policy Name&lt;| policy.</p>'); WITH UpdateCTE AS ( SELECT b.NewContent,STUFF(b.InnerText,b.StartIndex-5,b.EndIndex-b.StartIndex+10,'<a href="'+b.[Text]+'">'+b.[Text]+'</a>') AS ChangedText FROM ( SELECT a.*,SUBSTRING(a.InnerText,a.StartIndex,a.EndIndex-a.StartIndex) AS [Text] FROM ( SELECT PATINDEX('%Please refer to &lt;|%',t.OldContent)+21 AS StartIndex, PATINDEX('%&lt;| policy.%',t.OldContent) AS EndIndex, t.O

Categories : Sql Server

SQL: Replace Part Of a String in a Column for every row
I figured it out.. thanks to anyone who tried to help. First I had a few things wrong. For those who want to learn Since I already have a while@@ fetch i don't really need the loop BEGIN declare @subname varchar(70),@name1 varchar(50),@name varchar(50),@ID char(4), @location char(2) declare @pkey int,@IDLocation varchar(6) set @IDLocation='' set @name1='' DECLARE _cursor cursor for select pkey,name,ID,location from Table OPEN _cursor FETCH _cursor into @pkey, @name, @ID, @location while @@FETCH_STATUS = 0 Begin set @IDLocation = @ID+'-'+@location Select @subname= SUBSTRING(@name,1,CHARINDEX('-',@name)-1) set @name1= @subname+'-'+ @IDLocation Update Table set name=@name1 where pkey=@pkey Fetch _cursor into @pkey, @name, @ID, @location End close _

Categories : Sql Server

Function to replace values in column
To do this I normally nest ifelse commands, ifelse sets out like this: ifelse(definition e.g. a>b, gets "x" if definition met, gets "y" if definition not met) So this should work... data.frame$new.column <- ifelse ( data.frame$DEF=="0"&data.frame$FittedRobustRatio>0.6, "Del", ifelse( data.frame$DEF=="1"&data.frame$FittedRobustRatio<0.45, "Del2", "none")) I could be wrong as you have not provided a reproducible dataframe so I can't test this.

Categories : R

Locating the correct file within the Magento file structure
I haven't tried, but it should works Path hints is a very useful tool for Magento Theming as it let us know where exactly we have to go. It’s easy for front-end to enable the path hints and locate the template file because it is available by default but it is not set up for Admin area. To add option for Admin path hints in configuration page we need to hack the core code. find the file in app/code/core/Mage/Core/etc/system.xml and copy it in app/code/local/Mage/Core/etc/system.xml. It’s a good practice to always duplicate the core files in local directory. Look inside the Debug section, there will be label “Template Path Hints” and “Add Block Names to Hints” set 0 (zero). Simply change it to 1 (one). Next usual steps Clear System Cache

Categories : Magento

Batch file to find a replace a file path in a file
The replacement f, a la FOR ... %v IN (...) DO ... %~fv will resolve the path and make it a fully-qualified path. So, the requirement to get this to work is to get the path to the file(s) in a FOR loop variable. FOR /F "delims=*" %%f IN (list_of_files.txt) DO @ECHO %%~ff As for getting paths from a .CSPROJ file, I don't know the format. Can you say how the paths will be expressed? Are they XML element attributes or content? If they're not easy to find, this will be exceedingly unreliable depending on how the data is expressed.

Categories : Batch File

if data is string type replace to '0' for Column
I created function and it is working fine. i am uploading my function for future reference CREATE FUNCTION dbo.udf_GetNumeric_Nitish (@strAlphaNumeric VARCHAR(256)) RETURNS VARCHAR(256) AS BEGIN declare @test varchar(256) declare @intAlpha int select @intAlpha = ISNUMERIC(@strAlphaNumeric) if @intAlpha=1 set @test=@strAlphaNumeric else set @test='0' RETURN @test END

Categories : SQL

replace multiple values in a column for a single one
This would maintain your data structure (a factor like you guessed): x <- levels(a$T) levels(a$T) <- ifelse(x %in% c("E","S","T"), "AB", x) or levels(a$T)[levels(a$T) %in% c("E","S","T")] <- "AB" Edit: if you have many such replacements, it is a little more complicated but not impossible: from <- list(c("E","S","T"), c("J", "K", "L")) to <- c("AB", "YZ") find.in.list <- function(x, y) match(TRUE, sapply(y, `%in%`, x = x)) idx.in.list <- sapply(levels(a$T), find.in.list, from) levels(a$T) <- ifelse(is.na(idx.in.list), levels(a$T), to[idx.in.list]) a$T # [1] AB F G H I YZ YZ YZ M N O P Q R AB AB # Levels: AB F G H I YZ M N O P Q R

Categories : R

MySQL replace info of some rows of one column
What you want to use is the Update statement. In your case, you will have something like this : UPDATE jml_vm_product SET product_weight = "20.000" WHERE your_SKUs_column LIKE 'KC%';

Categories : Mysql

Replace string in a column using query in Oracle
The following from Tech on the Net may help: REPLACE('User House Name is ABC', 'House Name', 'House Number'); would return 'User House Number is ABC' REPLACE('123tech123', '123'); would return 'tech' REPLACE('222tech', '2', '3'); would return '333tech' REPLACE('0000123', '0'); would return '123' REPLACE('House Name', 'House Name', 'House Number'); would return 'House Number'

Categories : SQL

How to replace space by character in a specific column?
If you are in fact talking about the 1750960-th character on a line this is a nifty way to go about it echo $YOUR_LINE | sed 's|(.{1750959}).|10|' the( and )' take whatever is matched inside them and relates it back to1` to be used in the replacement. I hope this helps

Categories : Linux

How to replace returned column value in SQL SELECT query?
A bit clumsy,but try SELECT ib.incident_id, ib.incident_status_id, ( SELECT st.NAME FROM cs_incident_statuses_tl st WHERE st.incident_status_id = ib.incident_status_id ) StatusName FROM cs_incidents_all_b ib, cs_incidents_all_tl it WHERE ib.incident_id = it.incident_id AND ib.incident_status_id IN ( SELECT st.incident_status_id FROM cs_incident_statuses_tl st WHERE st.NAME IN ('Accept Order', 'Order Accepted', 'Address Retrieved', 'Analyze', 'Entered', 'Information Retrieved', 'Retrieve Address', 'Retrieve Information', 'Returned'));

Categories : SQL

Efficiently replace text from column within large CSV
Your second solution works faster because it does not put all the file in memory. You can try to change it like that : $filename = 'Dump.csv' Import-csv $filename -Delimiter '|' | foreach { $_.URL = $_.URL -replace '^"*(w*)://([^/]*)/(.*)$','$1://$2'; $_ } |export-csv 'DumpParsed.csv'

Categories : SQL

Replace a part of a varchar2 column in Oracle
To accomplish this, you can either use character functions such as substr(), replace() or a regular expression function - regexp_replace() for instance. SQL> with t1(col) as( 2 select 'TEMPORARY-2 TIME ECS BOUND -04-Insuficient Balance' 3 from dual 4 ) 5 select concat(substr( col, 1, 11), ' X') as res_1 6 , regexp_replace(col, '^(w+-d+)(.*)', '1 X') as res_2 7 from t1 8 ; Result: RES_1 RES_2 ------------- ------------- TEMPORARY-2 X TEMPORARY-2 X So your update statement may look like this: update your_table t set t.col_name = regexp_replace(col_name, '^(w+-d+)(.*)', '1 X') -- where clause if needed.

Categories : Regex

Indexing column with REPLACE function in mySQL
There is no such thing as computed column in MySQL. If you want to format some value to speed-up index search, you will probably have to use some trigger. As a matter of fact, I answered almost the same question this morning: see http://stackoverflow.com/a/18047511/2363712 for a similar example. In your case, that would lead to something like that: CREATE TABLE `table_a`(`column_1` VARCHAR(255), ... , `column_1_fmt` VARCHAR(255), INDEX(`column_1_fmt`)); CREATE TRIGGER ins_table_a BEFORE INSERT ON `table_a` FOR EACH ROW SET NEW.`column_1_fmt` = REPLACE(NEW.column_1, '-', ''); CREATE TRIGGER upd_table_a BEFORE UPDATE ON `table_a` FOR EACH ROW SET NEW.`column_1_fmt` = REPLACE(NEW.column_1, '-', ''); Now you will use column_1_fmt to

Categories : Mysql

Replace spaces with dash and copy into new column
You should be able to do this via the following query: UPDATE city SET slugs=LOWER(REPLACE(city_name, " ", "-")) Breaking this down, we're using REPLACE to swap all instances of " " with "-" in the existing city_name column, and then passing the result of this to the LOWER function (to convert the data to lower case) before setting the slugs field with this value. Depending on how "clean" your data is, you might also want to TRIM the data (to remove any leading or trailing spaces in the city_name field) before you apply the REPLACE as such: UPDATE city SET slugs=LOWER(REPLACE(TRIM(city_name), " ", "-")) Incidentally, if you've not used (My)SQL much I'd recommend a read of the String Functions manual page - the time you spend on this now will more than repay itself in the future.

Categories : Mysql

How to replace a column data in linux output - may be using awk sed etc
$ cat foo.input drwxrwxr-x 2 root root 5512 Aug 22 2013 bin lrwxrwxrwx 1 root root 7 Aug 22 2013 bin/addgroup -> busybox lrwxrwxrwx 1 root root 7 Aug 22 2013 bin/adduser -> busybox lrwxrwxrwx 1 root root 7 Aug 22 2013 bin/ash -> busybox $ cat foo2.input drwxrwxr-x 2 root root 0 Aug 22 09:32 bin lrwxrwxrwx 1 root root 7 Aug 22 09:24 bin/addgroup -> busybox lrwxrwxrwx 1 root root 7 Aug 22 09:24 bin/adduser -> busybox lrwxrwxrwx 1 root root 12345 Aug 22 09:24 bin/ash -> busybox $ diff <(awk '/^d/{$5=0}{$6=$7=$8=""}1' foo.input) <(awk '/^d/{$5=0}{$6=$7=$8=""}1' foo2.input) 4c4 < lrwxrwxrwx 1 root root 7 bin/ash -> busybo

Categories : Linux

Concatenate columns(user selected) and replace them with new column
I have removed the inputbox for selection of the category columns. Since they are always named Level x»y it makes it easier to find them automatically. That's why added a FindColumns() Sub to your code. It assigns the first fCol and last lCol Category column to global variables. The ConcatenateColumns() concatenates cells in each row using "|" as separator. The DeleteColumns() deletes the other columns Cells(1, fCol).Value = "Category renames Level 1 to Category and Columns.AutoFit resizes all columns widths to fit the text. Code: Option Explicit Dim fCol As Long, lCol As Long Sub cleanData() Dim rngMyrange As Range Dim cell As Range On Error Resume Next Do 'Cleans Status column Set rngMyrange = Application.InputBox _

Categories : Excel



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.